×

css实例

CSS样式ID 选择器的运用还有伪类··请举实例?css怎么写或者谁能给我一个简单的网站的css样式例子

admin admin 发表于2022-07-10 06:51:14 浏览88 评论0

抢沙发发表评论

CSS样式ID 选择器的运用还有伪类··请举实例


第一,#id2{还写CSS选择器是错误做法}
第二,写CSS,建议用工具调试,例如火狐的firebug和Chrome自带的审查网页的工具(F12)。这样选中html标签,右侧自动会显示出来所有的css属性,也方便看哪个把哪个给覆盖了,哪个权重高。
不会用工具调试的前端不是好前端啊!

css怎么写或者谁能给我一个简单的网站的css样式例子


《style》
.a {
background:#CCC;
height:80px;
width:440px;
overflow:hidden;
}
.b {
background:#f00;/*是图片位置*/
float:left;
height:80px;
overflow:hidden;
margin:0 5px;
position:relative;
width:100px;
}
.b span {
background:#000;
bottom:0;
color:#fff;
font-size:12px;
line-height:20px;
height:20px;
position:absolute;
width:100px;
overflow:hidden;
text-align:center;
filter: alpha(opacity=50);/*调整文字透明度*/
-moz-opacity:0.5; /*调整文字透明度*/
opacity: 0.5; /*调整文字透明度*/
}
《/style》
《div class=“a“》
《div class=“b“》
《span》文字1《/span》
《/div》
《div class=“b“》
《span》文字1《/span》
《/div》
《div class=“b“ style=“color:#f00;“》
《span》文字1《/span》
《/div》
《div class=“b“》
《span》文字1《/span》
《/div》
《/div》
差不多就这样!

如何用DIV+CSS布局例子


举例(两列布局):

《!DOCTYPE html》
《html》
 
    《head》
        《meta charset=“utf-8“》
        《title》练习使用HTML《/title》
        《link rel=“stylesheet“ href=“css/index.css“ /》
    《/head》
 
    《body》
        《!-- DIV --》
        《div id=“d1“》
            《span》DIV《/span》
        《/div》
        《div id=“d2“》
            《span》DIV《/span》
        《/div》
        《div id=“d3“》
            《span》DIV《/span》
        《/div》
    《/body》
 
《/html》
css代码:

css文件:

#d1{
    position: absolute;
    width: 100px;
    height: 100px;
    background-color: red;
}
#d2{
    position: absolute;
    margin-left: 100px;
    width: 500px;
    height: 100px;
    background-color: blue;
}
#d3{
    position: absolute;
    margin-top: 100px;
    width: 600px;
    height: 100px;
    background-color: yellow;
}

效果: