2016-03-31 28 views
0

在一個項目上工作時,做了一些標準的內嵌塊元素。爲了讓計數顯示到正確的區域,我必須將負數放在最高點。我不確定爲什麼它不會僅僅依靠自己的位置。這是因爲計數題目佔用了一個區域還是別的什麼?我想知道爲什麼我必須這樣做,如果未來有更好的方法避免這樣做,或者如果我做得對,並且如何確定發生了什麼,那麼我可以確保以同樣的方式執行此操作在將來。爲什麼在這種情況下需要一個負邊界頂點

https://jsfiddle.net/ybh9qz37/

.count-display { 
    height: 35px; 
    width: 65px; 
    background: black; 
    color: red; 
    display: flex; 
    float: left; 
    align-items: center; 
    border-radius: 5px; 
//why is this needed 
    margin-top: -60px; 
    margin-left: 40px; 
    font-family: Orbitron, sans-serif; 
    font-size: 200%; 
} 
+0

你'嚴格-button'類的是由於其'計數display'得到了轉移高度的一個良好的金額向下。因此您必須添加負值保證金。 – geeksal

+0

也許我誤解內聯塊,但不應該這樣,因爲嚴格的按鈕是在右邊?或者我錯誤地想象它 –

+0

它不是關於內聯塊它是關於浮動只是指我的答案。 – geeksal

回答

0

組織任何div有很多的div的最好辦法是組細分值。

例如,在你的情況下,你有3個細分不同高度下一個。這導致了很多問題,你應該使用這個模式:

<div class="row2"> 
    // your left side div 
    <div class="left" style="display: inline-block;vertical-align: top;"> 
     <span class="count-title">Count</span> 
     <span class="count-display"><p>00</p></span> 
    </div> 
    // the right way is to create here <div class='right'> with similar styles as left   
    <span class="strict-button"> 
     <a rel="external" href="#button" class="button">Strict</a> 
     <span></span> 
    </span> 

</div 

,改變你的.count-title到:

.count-title { 
    display:block; 
} 

這樣,您就可以輕鬆地擴展在未來的stucture沒有問題,並將其保存組織

相關問題