Css 单击选项卡时更改背景色
单击选项卡时,如何将背景更改为完全相同的颜色?目前,它只是保持相同的颜色。此外,在加载页面时,是否可以将第一个选项卡的颜色与内容区域的背景颜色相同Css 单击选项卡时更改背景色,css,Css,单击选项卡时,如何将背景更改为完全相同的颜色?目前,它只是保持相同的颜色。此外,在加载页面时,是否可以将第一个选项卡的颜色与内容区域的背景颜色相同 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>CSS-TABS | CSS-Only "DOM TABS"</title>
<style type="text/css">
#pagewidth { width: 760px; margin: 0 auto 0 auto; }
#navigation { margin: 0 10em 0 0; background: #000000; color: #FFFFFF; }
#navigation li { display: inline; padding: 0 2em 0 2em; }
.content { background: #CCCCCC; height: 20em; padding: 1em;}
a { color: #0066FF; }
a:hover { color: #00CCFF; }
a:active { font-weight:bold; }
#container { height: 20em; overflow: hidden; }
</style>
</head>
<body>
<div id="pagewidth">
<ul id="navigation">
<li><a href="#c1">Content Block 1</a></li>
<li><a href="#c2">Content Block 2</a></li>
<li><a href="#c3">Content Block 3</a></li>
</ul>
<div id="container">
<div class="content">
<a name="c1" id="c1"></a>
<h1>Heading 1</h1>
<p>Here is some content, I hope that you like it!</p>
</div>
<div class="content">
<a name="c2" id="c2"></a>
<h2>Heading 2</h2>
<p>Now that you have read content block 1, you can learn more in this block</p>
</div>
<div class="content">
<a name="c3" id="c3"></a>
<h3>Heading 3</h3>
<p>In conclusion, content blocks are fun</p>
</div>
</div> <!-- end container -->
</div> <!-- end pagewidth -->
</body>
</html>
CSS-TABS |仅CSS的“DOM选项卡”
#页面宽度{宽度:760px;边距:0自动0自动;}
#导航{边距:0 10em 0;背景:#000000;颜色:#FFFFFF;}
#导航li{显示:内联;填充:0 2em 0 2em;}
.content{背景:#CCCCCC;高度:20em;填充:1em;}
a{color:#0066FF;}
a:悬停{color:#00CCFF;}
a:活动{font-weight:bold;}
#容器{高度:20em;溢出:隐藏;}
标题1
这里有一些内容,希望大家喜欢
标题2
现在您已经阅读了内容块1,您可以在此块中了解更多信息
标题3
总之,内容块很有趣
您只需要多一点HTML,再多一点CSS,就像这样:
CSS添加了:
.content .sub{ height: 20em; padding: 1em; }
...
#sub1{ background: blue; }
#sub2{ background: green; }
#sub3{ background: yellow; }
以及:
。。。
。。。作为选项卡内容的包装
最后一页如下所示:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>CSS-TABS | CSS-Only "DOM TABS"</title>
<style>
#pagewidth { width: 760px; margin: 0 auto 0 auto; }
#navigation { margin: 0 10em 0 0; background: #000000; color: #FFFFFF; }
#navigation li { display: inline; padding: 0 2em 0 2em; }
.content { background: #CCCCCC; }
.content .sub{ height: 20em; padding: 1em; }
a { color: #0066FF; }
a:hover { color: #00CCFF; }
a:active { font-weight:bold; }
#container { height: 20em; overflow: hidden; }
#sub1{ background: blue; }
#sub2{ background: green; }
#sub3{ background: yellow; }
</style>
</head>
<body>
<div id="pagewidth">
<ul id="navigation">
<li><a href="#c1">Content Block 1</a></li>
<li><a href="#c2">Content Block 2</a></li>
<li><a href="#c3">Content Block 3</a></li>
</ul>
<div id="container">
<div class="content">
<a name="c1" id="c1"></a>
<div class="sub" id="sub1">
<h1>Heading 1</h1>
<p>Here is some content, I hope that you like it!</p>
</div>
</div>
<div class="content">
<a name="c2" id="c2"></a>
<div class="sub" id="sub2">
<h2>Heading 2</h2>
<p>Now that you have read content block 1, you can learn more in this block</p>
</div>
</div>
<div class="content">
<a name="c3" id="c3"></a>
<div class="sub" id="sub3">
<h3>Heading 3</h3>
<p>In conclusion, content blocks are fun</p>
</div>
</div>
</div> <!-- end container -->
</div> <!-- end pagewidth -->
</body>
</html>
CSS-TABS |仅CSS的“DOM选项卡”
#页面宽度{宽度:760px;边距:0自动0自动;}
#导航{边距:0 10em 0;背景:#000000;颜色:#FFFFFF;}
#导航li{显示:内联;填充:0 2em 0 2em;}
.内容{背景:#中交}
.content.sub{高度:20em;填充:1em;}
a{color:#0066FF;}
a:悬停{color:#00CCFF;}
a:活动{font-weight:bold;}
#容器{高度:20em;溢出:隐藏;}
#sub1{背景:蓝色;}
#sub2{背景:绿色;}
#sub3{背景:黄色;}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>CSS-TABS | CSS-Only "DOM TABS"</title>
<style>
#pagewidth { width: 760px; margin: 0 auto 0 auto; }
#navigation { margin: 0 10em 0 0; background: #000000; color: #FFFFFF; }
#navigation li { display: inline; padding: 0 2em 0 2em; }
.content { background: #CCCCCC; }
.content .sub{ height: 20em; padding: 1em; }
a { color: #0066FF; }
a:hover { color: #00CCFF; }
a:active { font-weight:bold; }
#container { height: 20em; overflow: hidden; }
#sub1{ background: blue; }
#sub2{ background: green; }
#sub3{ background: yellow; }
</style>
</head>
<body>
<div id="pagewidth">
<ul id="navigation">
<li><a href="#c1">Content Block 1</a></li>
<li><a href="#c2">Content Block 2</a></li>
<li><a href="#c3">Content Block 3</a></li>
</ul>
<div id="container">
<div class="content">
<a name="c1" id="c1"></a>
<div class="sub" id="sub1">
<h1>Heading 1</h1>
<p>Here is some content, I hope that you like it!</p>
</div>
</div>
<div class="content">
<a name="c2" id="c2"></a>
<div class="sub" id="sub2">
<h2>Heading 2</h2>
<p>Now that you have read content block 1, you can learn more in this block</p>
</div>
</div>
<div class="content">
<a name="c3" id="c3"></a>
<div class="sub" id="sub3">
<h3>Heading 3</h3>
<p>In conclusion, content blocks are fun</p>
</div>
</div>
</div> <!-- end container -->
</div> <!-- end pagewidth -->
</body>
</html>