2016-04-28 52 views
1

margin-top似乎不适合我。保证金 - 左边工作正常。但是,当我使用margin-top时,没有任何动作。即使我把它设置为一个荒谬的数字。为什么保证金顶不移动东西?

我的HTML:

<link rel="stylesheet" type="text/css" href="css/pricepages.css" media="screen" /> 
<div class="container-fluid "> 
    <div class="row"> 
    <img src="{{var protoHost}}img/Internet.jpg" class="col-xs-0 img-responsive"/> 
     <div class="contactspacer"> </div> 
     <div class="DSLBlurb"> 
      <a href="Internet/DSL">Home DSL</a> 
     </div> 
    </div> 
</div> 

我的CSS:

.DSLBlurb { 
    background-color: #277FD8; 
    color: white; 
    margin-left: 100px; 
    width: 100px; 
    height: 100px; 
    border-radius: 10px; 
} 
.DSLBlurb a { 
    color: white; 
    margin-top: 10px; 
    margin-left: 16px; 
} 

还有什么问题可能是什么?谢谢。

+0

[为什么这个CSS margin-top样式不起作用?](http://stackoverflow.com/questions/9519841/wh y-does-this-css-margin-top-style-not-work) – chazsolo

回答

3

<a>默认CSS值为inline所以请尝试将其更改为inline-blockblock任何适合您的更好。

所以:

.DSLBlurb a { 
    color: white; 
    margin-top: 10px; 
    margin-left: 16px; 
    display: inline-block; 
} 
+0

打我吧:) –

+0

谢谢!它解决了这个问题。你得到一个upvote和一个接受! –

+0

那么,一个在9分钟内接受。 –

0

试着给你的标签位置相对&顶级属性是这样的:

color: white; 
/* margin-top: 10px !important; */ 
margin-left: 16px; 
position: relative; 
top: 10px; 
0

首先,你甚至不需要保证金,你就可以说:

//Dont use pixels use % different screens have different needs. 

.DSLBlurb a { 
    color: white; 
    top: 10%; 
    left: 16%; 
}