当前位置

首页 > 综合知识 > 怎么写css样式

怎么写css样式

推荐人: 来源: 秒知社 阅读: 2.7W 次
1. css样式 怎么写

手写了一个例子:

怎么写css样式

<html>

<head>

<style type="text/css">

.fl {float:left;}

.top .fl {width:28%; text-align:left;background-color:red;}

</style>

</head>

<body>

<div class="top">

<span class="fl">fl</span>

</div>

<br />

<span class="fl">fl</span>

</body>

</html>

效果如图,第一个span是包含在div里的(div 的class为top),为了能看清楚,加了红色的背景。可以看出,红色部分正好是页面宽度的28%(371px/1366px约等于28%)。而第二个,没有包含在div里的span,没有红色背景,显然是不受.top .fl {width:28%; text-align:left;background-color:red;}影响。。。当然咯,你自己测试的时候可以加上.top{***********},体会体会。。。不懂的话,追问咯 ^_^

2. 怎样写CSS样式代码

CSS的定义由三个部分构成:选择符(selector),属性(properties)和属性的取值(value)。

CSS语法:

selector {property: value}

选择符 {属性:值}

选择符有多种:类型选择符、通配选择符、属性选择符等。

类型选择符:一般是你要定义样式的HTML标记,例如BODY、P、TABLE……,你可以通过此方法定义它的属性和值,属性和值要用冒号隔开。

例子:body {color: black},此例的效果是使页面中的文字为黑色。

如果需要对一个选择符指定多个属性时,我们使用分号将所有的属性和值分开。

例子:p {text-align: center; color: red} (段落居中排列;并且段落中的文字为红色)

这里只是最基本的写法,建议你去找教程学习,比如w3cschool里的CSS教程。

在此推荐经典教程《精通CSS》。

参考资料里有一些稍微详细的内容,建议你看一看。

3. Css的样式怎写

.zt1 {

font-family: Arial, Helvetica, sans-serif;

font-size: 30px;

text-indent: 20px;

}

body {

margin-left: 0px;

margin-top: 0px;

margin-right: 0px;

margin-bottom: 0px;

background-image: none;

background-color: #EBEBEB;

}

4. 这个样式用css怎么写

css样式:

.gavin_design{margin:0 auto; overflow:hidden; display:block;}

.gd .fl{float:left;}

.gd .fr{float:right;}

.gd .tri{height:0; width:0; overflow:hidden; font-size:0; line-height:0; border-width:15px;}

.gd .rtri{border-color:transparent transparent #7caaff #7caaff; border-style:dashed dashed solid solid;}

.gd .ltri{border-color:#7caaff #7caaff transparent transparent; border-style:solid solid dashed dashed;}

.gd ul ,.gd ul li{list-style:none; margin:0; padding:0; overflow:hidden;}

.gd ul li i{display:block; font-style:normal; white-space:nowrap;}

.gd ul li{float:left; margin-left:-20px;}

.gd ul li.step1{margin-left:0;}

.gd ul li .text{background:#7caaff; color:#555; padding:0 10px; width:200px; height:30px; line-height:30px;}

.gd ul li.focus .text{background:#2673ff; color:#fff; font-weight:bold;}

.gd ul li.focus .rtri{border-color:transparent transparent #2673ff #2673ff;}

.gd ul li.focus .ltri{border-color:#2673ff #2673ff transparent transparent;}

html代码:

1.选择退款货品

2.填写退款原因、余额

3.退款处理

4.退款完成

仅供参考,希望能帮助到你。

5. 这个样式用css怎么写

css样式: <style>.gavin_design{margin:0 auto; overflow:hidden; display:block;}.gd .fl{float:left;}.gd .fr{float:right;}.gd .tri{height:0; width:0; overflow:hidden; font-size:0; line-height:0; border-width:15px;}.gd .rtri{border-color:transparent transparent #7caaff #7caaff; border-style:dashed dashed solid solid;}.gd .ltri{border-color:#7caaff #7caaff transparent transparent; border-style:solid solid dashed dashed;}.gd ul ,.gd ul li{list-style:none; margin:0; padding:0; overflow:hidden;}.gd ul li i{display:block; font-style:normal; white-space:nowrap;}.gd ul li{float:left; margin-left:-20px;}.gd ul li.step1{margin-left:0;}.gd ul li .text{background:#7caaff; color:#555; padding:0 10px; width:200px; height:30px; line-height:30px;}.gd ul li.focus .text{background:#2673ff; color:#fff; font-weight:bold;}.gd ul li.focus .rtri{border-color:transparent transparent #2673ff #2673ff;}.gd ul li.focus .ltri{border-color:#2673ff #2673ff transparent transparent;}</style>html代码: 1.选择退款货品 2.填写退款原因、余额 3.退款处理 4.退款完成 仅供参考,希望能帮助到你。

6. CSS样式表怎么做

1、创建使用css样式表有三种,分别是外部样式表,内部样式表和内联样式。下面通过一个小demo演示它们的用法,首先新建一个html文件,放入3个button按钮,给前两个按钮分别设置class属性为btn1和btn2:

2、接着准备一个css文件,命名为demo.css,在文件内写入按钮A的样式,保存css文件:

3、回到刚才的html文件,在style标签中用link标签引入上一步创建的css文件,这就是外联样式的用法,总结就是创建好的css文件内写好样式,然后在html文件中用link标签引入即可,这也是大部分网站使用的方法,因为其引入方便,管理起来也比较方便:

4、接着是内部样式表的使用,这里直接在head标签里创建style标签,在里面加入btn2的样式。对于内部样式表简单的html文件,内部样式是很方便的,但是结构复杂的html文件使用它就会让文件显得很混乱:

5、最后是内联样式的使用,直接在第三个标签内使用style属性加入样式就可以了:

6、最后保存html文件,打开浏览器可以看到三个按钮的样式都出现了。以上就是css样式表的制作方法:

7. 这样的DIV

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "

<html xmlns="

<head>

<meta ; charset=utf-8" />

<title>;无标题文档</title>

<style type="text/css">

<!--

strong { text-align:center; background-color:#0C0}

-->

</style>

</head>

<body>

<div style=" width:250px;">

<strong>;内容标题</strong>

这就是内容这就是内容这就是内容这就是内容这就是内容这就是内容<img name="guanggao" src="" width="100" height="100" alt="" style=" background-color:#00C;" />;就是内容就是内容就是内容就是内容就是内容就是内容就是内容就是内容就是内容就是内容就是内容就是内容就是内容就是内容就是内容就是内容就是内容

</div>

</body>

</html>