我正在尝试添加1px黑色边框以及插入框阴影。出于某种原因,我的代码无效。我是CSS和HTML的新手,所以请各位成员请给我初学友好的建议。
它看起来如何(底部)以及它应该如何(顶部) - 排除大小和字体的变化。我只想要相同的阴影和边框造型。
Jfiddle: https://jsfiddle.net/kad7g4uf/
HTML:
<div id="navContainer">
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Website Design</a></li>
<li><a href="#">Art & Poetry</a></li>
<li><a href="#">Blog & Other</a></li>
<li><a href="#">Music & More</a></li>
<li><a href="#">Shop</a></li>
</ul>
</nav>
</div><!--end of nav container div-->
CSS:
.container {
width: 960px;
padding: 0 10px;
margin: 0 auto;
}
#navContainer {
width: 100%;
}
#navContainer nav {
width: 960px;
margin-left: auto;
margin-right: auto;
}
#navContainer ul {
list-style: none;
list-style-type: none;
padding: 0px 0px;
margin: 0px 0px;
}
#navContainer li {
float: left;
width: 16.666667%;
text-align: center;
}
#navContainer a {
text-decoration: none;
display: block;
background-color: #005073;
line-height: 30px;
height: 30px;
}
#navContainer a {
text-decoration: none;
display: block;
background-color: #005073;
line-height: 30px;
color: #EBEAEA;
text-shadow:
-1px -1px 1px rgba(0, 0, 0, .6),
1px -1px 1px rgba(0, 0, 0, .6),
-1px 1px 1px rgba(0, 0, 0, .6),
1px 1px 1px rgba(0, 0, 0, .6);
font-weight: 600;
background-image: -webkit-linear-gradient(rgba(0,0,0,.2), rgba(125,125,125,.3)); /* For Safari 5.1 to 6.0 */
background-image: -o-linear-gradient(rgba(0,0,0,.2), rgba(125,125,125,.3)); /* For Opera 11.1 to 12.0 */
background-image: -moz-linear-gradient(rgba(0,0,0,.2), rgba(125,125,125,.3)); /* For Firefox 3.6 to 15 */
background-image: linear-gradient(rgba(0,0,0,.2), rgba(125,125,125,.3)); /* Standard syntax */
}
#navContainer a:hover {
color: #E1E0E0;
background-image: -webkit-linear-gradient(rgba(0,0,0,.3), rgba(0,0,0,.2)); /* For Safari 5.1 to 6.0 */
background-image: -o-linear-gradient(rgba(0,0,0,.3), rgba(0,0,0,.2)); /* For Opera 11.1 to 12.0 */
background-image: -moz-linear-gradient(rgba(0,0,0,.3), rgba(0,0,0,.2)); /* For Firefox 3.6 to 15 */
background-image: linear-gradient(rgba(0,0,0,.3), rgba(0,0,0,.2)); /* Standard syntax */
}
Jfiddle上面的代码
答案 0 :(得分:1)
CSS
#navContainer {
width: 100%;
border : 1px solid #000;
background-color: #005073;
}
.shadow {
-moz-box-shadow: inset 0 0 10px #000000;
-webkit-box-shadow: inset 0 0 10px #000000;
box-shadow: inset 0 0 10px #000000;
}
HTML
<div id="navContainer" class="shadow">
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Website Design</a></li>
<li><a href="#">Art & Poetry</a></li>
<li><a href="#">Blog & Other</a></li>
<li><a href="#">Music & More</a></li>
<li><a href="#">Shop</a></li>
</ul>
</nav>
<div style="clear:both"></div> <!-- I've add this code -->
</div><!--end of nav container div-->
Why doesn't the height of a container element increase if it contains floated elements?
这就是你必须添加此代码的原因
你必须删除你的css&#34; #navContainer a&#34;
中的bakcground-color属性