Rendered div height different when margin and height value different











up vote
0
down vote

favorite












I am trying to create a stack of lines using divs. What seems to be a relatively simple task has left me boggled because the rendered height of the divs are not the same while they are given the same height in css. Funny thing is, if the margin-bottom value is the same as the div height, div heights renders correctly. But, I want the margin to be twice that of the div height. Here is my code.






.line-wrap{
position: absolute;
top: 50%;
transform: translateY(-50%);
width: 400px;
}

.line{
background: rgb(0,0,0);
/* display: inline-block; */
/* display: flex; */
height: 2px;
width: 100%;
/* box-sizing: border-box; */
/*margin-bottom: 2px;*/
margin-bottom: 4px;

}

<div class="line-wrap">
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
</div>





I've tried different suggestions from different SO posts but nothing seems to work. What's happening here? What am I doing wrong? Thanks in advance for the help.










share|improve this question






















  • I'm not sure I understand the problem. I see six parallel lines of equal height, in Firefox and Chrome. What browser are you using? Can you include a screenshot? Here is mine: tarm.wdfiles.com/local--files/stack-overflow-files/lines.png
    – Auroratide
    Nov 11 at 9:00










  • funny stuff. I'm using chrome 70.0.3 & firefox 63.0.1 Tested with edge as well. Here is my screenshot. [ibb.co/n5TCYV]
    – Antonio
    Nov 11 at 14:32










  • New link pasteboard.co/HMGvxz8.png
    – Antonio
    Nov 11 at 14:52










  • @Antonio in this case, check if there is any zoom active
    – Temani Afif
    Nov 11 at 14:53










  • Nah, everything is normal.
    – Antonio
    Nov 11 at 14:58















up vote
0
down vote

favorite












I am trying to create a stack of lines using divs. What seems to be a relatively simple task has left me boggled because the rendered height of the divs are not the same while they are given the same height in css. Funny thing is, if the margin-bottom value is the same as the div height, div heights renders correctly. But, I want the margin to be twice that of the div height. Here is my code.






.line-wrap{
position: absolute;
top: 50%;
transform: translateY(-50%);
width: 400px;
}

.line{
background: rgb(0,0,0);
/* display: inline-block; */
/* display: flex; */
height: 2px;
width: 100%;
/* box-sizing: border-box; */
/*margin-bottom: 2px;*/
margin-bottom: 4px;

}

<div class="line-wrap">
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
</div>





I've tried different suggestions from different SO posts but nothing seems to work. What's happening here? What am I doing wrong? Thanks in advance for the help.










share|improve this question






















  • I'm not sure I understand the problem. I see six parallel lines of equal height, in Firefox and Chrome. What browser are you using? Can you include a screenshot? Here is mine: tarm.wdfiles.com/local--files/stack-overflow-files/lines.png
    – Auroratide
    Nov 11 at 9:00










  • funny stuff. I'm using chrome 70.0.3 & firefox 63.0.1 Tested with edge as well. Here is my screenshot. [ibb.co/n5TCYV]
    – Antonio
    Nov 11 at 14:32










  • New link pasteboard.co/HMGvxz8.png
    – Antonio
    Nov 11 at 14:52










  • @Antonio in this case, check if there is any zoom active
    – Temani Afif
    Nov 11 at 14:53










  • Nah, everything is normal.
    – Antonio
    Nov 11 at 14:58













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am trying to create a stack of lines using divs. What seems to be a relatively simple task has left me boggled because the rendered height of the divs are not the same while they are given the same height in css. Funny thing is, if the margin-bottom value is the same as the div height, div heights renders correctly. But, I want the margin to be twice that of the div height. Here is my code.






.line-wrap{
position: absolute;
top: 50%;
transform: translateY(-50%);
width: 400px;
}

.line{
background: rgb(0,0,0);
/* display: inline-block; */
/* display: flex; */
height: 2px;
width: 100%;
/* box-sizing: border-box; */
/*margin-bottom: 2px;*/
margin-bottom: 4px;

}

<div class="line-wrap">
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
</div>





I've tried different suggestions from different SO posts but nothing seems to work. What's happening here? What am I doing wrong? Thanks in advance for the help.










share|improve this question













I am trying to create a stack of lines using divs. What seems to be a relatively simple task has left me boggled because the rendered height of the divs are not the same while they are given the same height in css. Funny thing is, if the margin-bottom value is the same as the div height, div heights renders correctly. But, I want the margin to be twice that of the div height. Here is my code.






.line-wrap{
position: absolute;
top: 50%;
transform: translateY(-50%);
width: 400px;
}

.line{
background: rgb(0,0,0);
/* display: inline-block; */
/* display: flex; */
height: 2px;
width: 100%;
/* box-sizing: border-box; */
/*margin-bottom: 2px;*/
margin-bottom: 4px;

}

<div class="line-wrap">
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
</div>





I've tried different suggestions from different SO posts but nothing seems to work. What's happening here? What am I doing wrong? Thanks in advance for the help.






.line-wrap{
position: absolute;
top: 50%;
transform: translateY(-50%);
width: 400px;
}

.line{
background: rgb(0,0,0);
/* display: inline-block; */
/* display: flex; */
height: 2px;
width: 100%;
/* box-sizing: border-box; */
/*margin-bottom: 2px;*/
margin-bottom: 4px;

}

<div class="line-wrap">
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
</div>





.line-wrap{
position: absolute;
top: 50%;
transform: translateY(-50%);
width: 400px;
}

.line{
background: rgb(0,0,0);
/* display: inline-block; */
/* display: flex; */
height: 2px;
width: 100%;
/* box-sizing: border-box; */
/*margin-bottom: 2px;*/
margin-bottom: 4px;

}

<div class="line-wrap">
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
</div>






html css height margin






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 11 at 8:39









Antonio

63




63












  • I'm not sure I understand the problem. I see six parallel lines of equal height, in Firefox and Chrome. What browser are you using? Can you include a screenshot? Here is mine: tarm.wdfiles.com/local--files/stack-overflow-files/lines.png
    – Auroratide
    Nov 11 at 9:00










  • funny stuff. I'm using chrome 70.0.3 & firefox 63.0.1 Tested with edge as well. Here is my screenshot. [ibb.co/n5TCYV]
    – Antonio
    Nov 11 at 14:32










  • New link pasteboard.co/HMGvxz8.png
    – Antonio
    Nov 11 at 14:52










  • @Antonio in this case, check if there is any zoom active
    – Temani Afif
    Nov 11 at 14:53










  • Nah, everything is normal.
    – Antonio
    Nov 11 at 14:58


















  • I'm not sure I understand the problem. I see six parallel lines of equal height, in Firefox and Chrome. What browser are you using? Can you include a screenshot? Here is mine: tarm.wdfiles.com/local--files/stack-overflow-files/lines.png
    – Auroratide
    Nov 11 at 9:00










  • funny stuff. I'm using chrome 70.0.3 & firefox 63.0.1 Tested with edge as well. Here is my screenshot. [ibb.co/n5TCYV]
    – Antonio
    Nov 11 at 14:32










  • New link pasteboard.co/HMGvxz8.png
    – Antonio
    Nov 11 at 14:52










  • @Antonio in this case, check if there is any zoom active
    – Temani Afif
    Nov 11 at 14:53










  • Nah, everything is normal.
    – Antonio
    Nov 11 at 14:58
















I'm not sure I understand the problem. I see six parallel lines of equal height, in Firefox and Chrome. What browser are you using? Can you include a screenshot? Here is mine: tarm.wdfiles.com/local--files/stack-overflow-files/lines.png
– Auroratide
Nov 11 at 9:00




I'm not sure I understand the problem. I see six parallel lines of equal height, in Firefox and Chrome. What browser are you using? Can you include a screenshot? Here is mine: tarm.wdfiles.com/local--files/stack-overflow-files/lines.png
– Auroratide
Nov 11 at 9:00












funny stuff. I'm using chrome 70.0.3 & firefox 63.0.1 Tested with edge as well. Here is my screenshot. [ibb.co/n5TCYV]
– Antonio
Nov 11 at 14:32




funny stuff. I'm using chrome 70.0.3 & firefox 63.0.1 Tested with edge as well. Here is my screenshot. [ibb.co/n5TCYV]
– Antonio
Nov 11 at 14:32












New link pasteboard.co/HMGvxz8.png
– Antonio
Nov 11 at 14:52




New link pasteboard.co/HMGvxz8.png
– Antonio
Nov 11 at 14:52












@Antonio in this case, check if there is any zoom active
– Temani Afif
Nov 11 at 14:53




@Antonio in this case, check if there is any zoom active
– Temani Afif
Nov 11 at 14:53












Nah, everything is normal.
– Antonio
Nov 11 at 14:58




Nah, everything is normal.
– Antonio
Nov 11 at 14:58

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53247087%2frendered-div-height-different-when-margin-and-height-value-different%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53247087%2frendered-div-height-different-when-margin-and-height-value-different%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Bressuire

Vorschmack

Quarantine