【问题标题】:CSS background used in nav gets added to the body top导航中使用的 CSS 背景被添加到正文顶部
【发布时间】:2015-10-28 20:30:04
【问题描述】:

我在开始和后面的导航中有一个标题,我在导航中添加了一个线性渐变背景,但它被添加到了页面顶部。 我正在使用引导框架,我删除了字体文件夹中的所有字形图标并添加了它们的字体真棒字体。帮帮我,这是我的第一个付费项目。 JS 小提琴 - https://jsfiddle.net/m1aeo6nx/


HTML

<div class="container">
        <header>
            <div class="col-md-7">
                <img src="img/logo.png" alt="Rashidamonirtrust logo" class="img-responsive">
            </div>

            <div class="col-md-4 col-md-offset-1">
                <ul class="header-icons-list">
                    <li>
                        <a href=""><i class="fa fa-home header-icons"></i></a>
                        <a href=""><i class="fa fa-sitemap header-icons"> </i></a>
                        <a href=""><i class="fa fa-envelope header-icons"> </i></a>
                    </li>

                    <li>
                        <a href="" class="header-icons-text">Home</a>
                        <a href="" class="header-icons-text">Sitemap</a>
                        <a href="" class="header-icons-text">Contact Us</a>
                    </li>

                    <li>
                        <a href=""><img src="img/donate.png" class="img-responsive donate-img" alt="donate "></a>
                    </li>
                </ul>
            </div>
        </header>

         <nav> 
            <ul>

                <li> <a href="#">Home</a> </li>
                <li> <a href="aboutus.html">About Us</a> </li>
                <li> <a href="whoweare.html">Who We Are</a> </li>
                <li> <a href="mission.html">Mission</a> </li>
                <li> <a href="activities.html">Activities</a> </li>
                <li> <a href="gallery.html">Gallery</a> </li>
                <li> <a href="donate.html">Donate</a> </li>
                <li> <a href="sitemap.html">Sitemap</a> </li>
                <li> <a href="contactus.html">Contact Us</a> </li>

            </ul>
        </nav>

    </div><!-- .container -->

CSS

<style>

        html{
            background: #E5E5E5;
        }

        body{
            font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
            background: none;
        }

        header .header-icons-list{
            list-style: none;
        }

        header .header-icons{
            color: #191918;
            font-size: 1.2em;
            margin-right: 25%;
            margin-top: 2%;
            list-style: none;
        }

        header .header-icons-text{
            margin-right: 12%;
        }

        header .donate-img{
            margin-top: 6%;

        }


        nav {
                width: 100%;
                height: 40px;
                background: -webkit-linear-gradient(#3f9a15, #388813, #3f9a15, #388813, #3f9a15);
                background: -o-linear-gradient(#3f9a15, #388813, #3f9a15, #388813, #3f9a15);
                background: linear-gradient(#3f9a15, #388813, #3f9a15, #388813, #3f9a15);
                border-radius: 6px;
            }

        nav ul{
            list-style: none;
        }

        nav ul li{
            margin-right: 5%;
             display: inline-block;
        }

    </style>

【问题讨论】:

  • 我没看到,你用的是什么浏览器?可以加个截图吗?
  • 仔细看你的小提琴。仅在导航上添加绿色渐变背景。您正在努力实现的目标。

标签: twitter-bootstrap css font-awesome glyphicons


【解决方案1】:

您的标题仅包含浮动元素,因此您需要对其进行 clearfix。

What is a clearfix?

【讨论】:

    猜你喜欢
    • 2017-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多