dongqieli4164 2015-07-27 09:56
浏览 63

无法在外部css表中定义填充和边距

I'm trying to define some css styling to an < a > element, in particular, padding and margins. I've noticed that when I'm trying to define it in-line, it's working, but when I try to use a class selector in an external style sheet, for some reason it is not working. The weird thing is that other attributes (like height), does work in the external file.

The relevant php code:

    <div id='navbar_line'>
    <nav class="home_navbar">
    <div class="container">
        <div id="navbar" class="collapse navbar-collapse" style='padding:0'>
            <ul class="nav navbar-nav home_nav">
                <?php
                // Create the top navigation list by listing the children of the homepage.
                // If the section we are in is the current (identified by $page->rootParent)
                // then note it with <a class='on'> so we can style it differently in our CSS.

                $homepage = $pages->get( "/" );
                $children = $homepage->children;

                $reversed = $children->reverse();

                foreach ($reversed as $child) {
                    echo "<li class='home_navbar_item'>";
                    echo "<a href='{$child->url}'>";
                    echo "<div class='navbar_logo'>";
                    echo    "<img src='{$child->page_logo->url}' alt='{$child->title}' height='30' width='30'>";
                    echo "</div>";

                    echo "</a>";
                    echo "</li>";
                }


                echo "<li class='home_navbar_item'> <a href='{$homepage->url}'>";
                 echo    "<img src='{$meta_data->Logo->url}' alt='{$homepage->title}' height='30' width='30'>";
                 echo "</a>";
                 echo "</li>";
                ?>
            </ul>
        </div><!--/.nav-collapse -->
    </div>
    </nav>
</div>

The css code:

#lower_part span{
  padding:0; 
  margin:0;
  white-space: pre;
}


#navbar_line{
  background-color: #04619c;
  height: 137px;
  margin: auto;
}

#navbar{
  background-color: #04619c;
}

.home_navbar_item a {
  height: 300px;
  padding:0; 
  margin:0;
}

.navbar_logo{
  height: 50px;
  width: 50px;
  background-color: white;
  /*border-radius: 50%;*/
}

.carousel_image{
  width:100%;
}

.hebrew_text{
  text-align: right;
}


#scrollable_body{
  height: 100px;
  margin:0;
  padding:0;
}

.scrollable_content{
  padding:0;
  overflow: scroll; overflow-x:hidden;
  height: 500px;
  /*-webkit-overflow-scrolling: touch;*/
}

span{
  padding:4em 0 0 0;
  display:inline-block;
}

hr {
  border:none;
  border-top:1px dotted #f00;
  color:blue;
  background-color:#fff;
  height:1px;
  width:50%;
}
  • 写回答

1条回答 默认 最新

  • dongxu4580 2015-07-27 10:03
    关注

    Seems you just can't override previous defined padding & margin, while you doing that inline, inline styles have bigger priority and applies.

    Try to read this article, it can helps to understand a problem https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity

    评论

报告相同问题?

悬赏问题

  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因