如何为元素设置背景颜色

 1 <html xmlns="http://www.w3.org/1999/xhtml">
 2 <head>
 3
 4 <style type="text/css">
 5
 6 body {background-color: yellow}
 7 h1 {background-color: #00ff00}
 8 h2 {background-color: transparent}
 9 p {background-color: rgb(250,0,255)}
10
11 p.no2 {background-color: gray; padding: 20px;}
12
13 </style>
14
15 </head>
16
17 <body>
18
19 <h1>这是标题 1</h1>
20 <h1>这是标题 1.1</h1>
21 <h2>这是标题 2</h2>
22 <p>这是段落</p>
23 <p class="no2">这个段落设置了内边距。</p>
24
25 </body>
26 </html>

如何为元素设置背景颜色

时间: 2024-08-24 02:46:14

如何为元素设置背景颜色的相关文章

java JFrame 设置背景颜色无效的理解

广州疯狂软件教育Java培训,iOS培训分享 在开发Java应用程序时,通常情况下利用JFrame创建窗口.利用JFrame创建的窗口分别包含一个标题.最小化按钮.最大化按钮和关闭按钮 1.在你使用JFrame创建窗体时的情况: 在你直接调用setBackground(Color.red)这个方法后,你的确设置了JFrame的背景颜色,而你看到的却不是直接的JFrame,而是JFrame.getContentPane().而JFrame上的contentPane默认是Color.WHITE的,所

Pyqt 设置 背景颜色和背景图片

首先设置autoFillBackground属性为真然后定义一个QPalette对象设置QPalette对象的背景属性(颜色或图片)最后设置QWidget对象的Palette 实例: 1 # -*- coding: utf-8 -*- 2 import sys 3 from PyQt4 import QtGui 4 from PyQt4.QtGui import * 5 from PyQt4.QtCore import * 6 7 8 class Icon(QtGui.QWidget): 9 d

每日总结 - android设置背景颜色报错

每天坚持总结,总会发生质变! 今天给radiobutton设置背景颜色报错,信息如下: item> tag requires a 'drawable' attribute or child tag defining a drawable 解决方法: 你不能将颜色选择器用在background上,应该使用drawable selector. 1 <selector xmlns:android="http://schemas.android.com/apk/res/android&quo

Aspose.Cells 设置背景颜色

很多小伙伴设置背景颜色都不起作用,特别提醒需要加入下面一行: style.Pattern = BackgroundType.Solid; Aspose.Cells.Style style = null; int index = workbook.Styles.Add(); style = workbook.Styles[index]; //文本颜色 style.Font.Color = Color.Red; style.Font.Size = 10; //设置背景颜色 style.Foregro

codeblock 设置背景颜色

今天觉得codeblock看着刺眼,想了想,能不能跟vs利用dark背景一样可以设置一个舒服的背景.于是就开始各种点击,各种摸索了. 1. 背景和各种颜色设置 不妨先说下vs中的设置是:工具(Tools) -- 选项(Options) -- 环境(Environment) -- 常规(General) -- 颜色主题(Color theme) -- 深色/浅色(dark or light). codeblock设置背景颜色:settings -- editor -- syntax highlig

css设置背景颜色和处理背景图片样式

<!doctype html><html lang="en"> <head> <meta charset="UTF-8"> <title>css设置背景颜色和处理背景图片样式</title> <style> div{ width:1000px; height:500px;/*没有宽高不能加背景图片*/ border:1px solid #000000; /*background-co

Flutter - 给App增加启动屏幕(Splash Screen)并且设置背景颜色

先看一下效果图,启动图最好设置为png格式的透明图,以防图片填充不满的时候背景图会非常的煞白(Flutter 默认背景色是白色). 打开android\app\src\main\res\drawable\launch_background.xml, <?xml version="1.0" encoding="utf-8"?> <!-- Modify this file to customize your launch splash screen -

input标签设置背景颜色

给input的button按钮的点击事件添加背景颜色变化 1. $("#aa").style.backgroundColor = 'red'这种写法报错 2. $("#aa").css("background-color","gray");这种写法可以实现背景色的改变 原文地址:https://www.cnblogs.com/bulata/p/8176807.html

ios晋级之路-tableViewCell设置背景颜色

如果你项修改一下cell的颜色的话cell.contentView.backgroundColor = [UIColor redColor]; 这样是没有问题的,但是如果你想把其修改成无色,那么就不可以了. 所以 为了改变单元格的背景色,你需要修改: 1 2 3 4 - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)