简体   繁体   中英

Adding border and inset box shadow?

I'm trying to add a 1px black border in addition to a inset box shadow. For some reason my code isn't working. I'm very new to CSS and HTML so can you kind members please only give me beginner-friendly advice.

在此处输入图片说明

That's how it looks (bottom) and how it should look (top) - excluding the changes in size and font. I just would like the same shadow and border styling.

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 &amp; Poetry</a></li>  
                    <li><a href="#">Blog &amp; Other</a></li>
                    <li><a href="#">Music &amp; 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 above code

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 &amp; Poetry</a></li>  
                    <li><a href="#">Blog &amp; Other</a></li>
                    <li><a href="#">Music &amp; 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?

that is why you have to add this code

and you have to remove bakcground-color attribute in your css "#navContainer a"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM