css 调用二级栏目代码问题

html-css012

css 调用二级栏目代码问题,第1张

主要分3种方法:

1.行内式,就是直接在网页中加入css样式表,在标记的后面加上style属性来设定css样式。

如:

<p style="font-size:12pxcolor:#000">行内式测试</p>

注:读取速度最快,但维护最麻烦

2.嵌入式,在页面的<head>和</head>之间。

如:

<style type="text/css">

p{margin: 0padding: 0color:red}

</style>

注:读取速度居中,但维护也居中

3.连接式

<link href="style.css" rel="stylesheet" type="text/css"/>

注:读取速度不及上面2种,但维护较方便;网页设计师最常用~

用复合选择器来写可能要好一点 其他栏目div:hover 第一个栏目div:nth-child(0){display:none},

第一个栏目一开始要有其他样式的话,你需要给他一个单独的class,再写样式

很简单呀,看过来:

<body>

<div class="all">

<p>栏目标题</p>

<p><a href="#">更多>></a></p>

<div style="clear:both"></div>

</div>

</body>

<style>

a{ display:inline-blockcolor:#000text-decoration:none}

.all{ width:50%margin:0 autobackground:#cccpadding:0 20px}

.all p:first-child{ float:leftfont-size:16pxcolor:#000line-height:1.5}

.all p:nth-child(4n+2){ float:right}

</style>

还有不懂的可以继续问我。

纯手打,望采纳~