CSS样式表中的.homepage .sider { width: 230px; }

html-css013

CSS样式表中的.homepage .sider { width: 230px; },第1张

这个是homepage的子集,就是homepage包含的标签中class名为sider的标签应用的属性

<div class="homepage">

  <div class="mm">456789</div>

  <div class="nn">000000</div>

  <div class="slider">123456</div>

</div>

在上面的例子中,只有“123456”这个层的宽度才是230px,其他的都是默认的宽度

你可以在head部分,也可在标签内直接加,看下面:

<!DOCTYPE html>

<html>

<head>

<style>

#a1{color:#e981e9}

.a2{color:#5ee95e}

</style>

</head>

 

<body>

<a href="/a1.html" id="a1">a1</a>

<a href="/a2.html" class="a2">a2</a>

<a href="/a3.html" style="color:#e95e5e">a3</a>

</body>

</html>

以上3种方式都是在HTML页面加CSS,建议在head里比较好!

还有就是在外部CSS里加样式,这是最好的方法:

<!DOCTYPE html>

<html>

<head>

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

<!--href里的style.css是外部CSS表的路径,格式和上面的head中的CSS一样-->

</head>

 

<body>

<a href="/a1.html" id="a1">a1</a>

<a href="/a2.html" class="a2">a2</a>

</body>

</html>