hr line between two divs - html

Following is my fiddle in which I am trying to give hr line between two floating divs . Kindly let me know how can I give a responsive line between two floating divs.
http://jsfiddle.net/NH5Lc/5/
<div style="display:inline-block; float: left;">Calories</div>
<div style="inline-block">
<hr class="between" />
</div>
<div style="display:inline-block; float: right;">20</div>
<br/>
<div style="display:inline-block; float: left;">Calories</div>
<div style="inline-block">
<hr class="between" />
</div>
<div style="display:inline-block; float: right;">20</div>

You can use flex too. jsFiddle Live Demo
.between {
border: 3px dotted #0099CC;
margin-left:10px;
margin-right:10px;
}
.parent
{
display:-moz-box; /* Firefox */
display:-webkit-box; /* Safari and Chrome */
display:-ms-flexbox; /* Internet Explorer 10 */
display:box;
width:100%;
}
.child2
{
-moz-box-flex:5.0; /* Firefox */
-webkit-box-flex:5.0; /* Safari and Chrome */
-ms-flex:9.0; /* Internet Explorer 10 */
box-flex:9.0;
}
<div class='parent'>
<div class='child1'>Calories</div>
<div class='child2'> <hr class="between" /></div>
<div class='child3'>20</div>
</div>
<div class='parent'>
<div class='child1'>Calories as dasd as dasd</div>
<div class='child2'> <hr class="between" /></div>
<div class='child3'>20</div>
</div>

paste it your between class
.between {
width: 500px;
float: left;
border-right: 1px solid gray;
}

<div style="border-top:1px solid black; width:100%;"></div> will do it. As Gert B. says, you should really be using a linked file rather than inline styles though. In which case, you would have in your CSS file:
.line{
border-top:1px solid black;
width:100%
}
Then in your markup:
<div class="line"></div>

it seems like you could use a <table> or at least a list <ul> for what you are trying to do .
With a list, you can use text-align, float and pseudo-element .
http://codepen.io/gc-nomade/pen/Bmhqc
ul, li {
padding:0;
margin:0;
list-style-type:none;
text-align:right;
}
li em {
float:left;
}
li em:after {
content:'';
border-bottom:dotted;
width:2000px;
margin-right:-2000px;/* reduce space needed to 0 */
display:inline-block;
vertical-align:middle;
}
li, span {
background:white;
overflow:hidden; /* hide pseudo line overflow */
}
<ul>
<li><em>calorie</em><span>20</span></li>
<li><em>calorie</em><span>20</span></li>
<li><em>calorie</em><span>20</span></li>
<li><em>calorie</em><span>20</span></li>
</ul>

Html
<div id="outer">
<div id="left">Calories</div>
<div id="middle">
<hr class="between" />
</div>
<div id="right">20</div>
</div>
<br>
<br>
<div id="outer">
<div id="left">Calories</div>
<div id="middle">
<hr class="between" />
</div>
<div id="right">20</div>
</div>
CSS
#outer {
display:block;
width: 100%;
}
#left {
width: 100px;
float: left;
text-align:center;
}
#right {
width: 200px;
float: right;
text-align:center;
}
#middle {
float: left;
}
.between {
border: 3px dotted #0099CC;
width:200px;
margin-left:10px;
margin-right:10px;
}
Output:
Working fiddle

Related

After adding float:left the layout is not the way is supposed to be

I've been trying to add two div containers into another one. One floating on the left and the other one on to the right side of the main container. The problem is, if I add float:left on the first div, it's no longer contained in the main container.
Before adding float: https://imgur.com/a/OACA7Su
After adding it: https://imgur.com/a/ukeZoae
HTML:
<div class="container">
<div class="column1">
<div class="rowTop">
<p>Community</p>
</div>
<div class="row">
<div id="leftSide">
<h3><a>Disscusion</a></h3>
<p>&#8594 Disscusions about various games like Warframe or HuntShowdown</p>
</div>
<div id="rightSide">
0:Threds
</div>
</div>
<div class="row">
</div>
<div class="row">
</div>
</div>
<div class="column2">
</div>
</div>
CSS:
.container{
margin:30px;
}
.column1{
width:70%;
float:left;
}
.column2{
width:15%;
float:right;
padding:2px;
}
.rowTop{
background-color: rgb(0, 51, 0);
border:1px solid white;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
width:10%;
text-align: center;
text-shadow: black 1px 1px;
color:white;
}
.row{
background-color: black;
border:1px solid white;
color:white;
display: block;
padding:0;
}
.row #leftSide{
color:white;
float: left;
margin-right: 0;
width: 55%;
}
Thanks in advance for the help.
Please don't give me any hate, I'm new to coding :3
You can use Flexbox for this. Check out the guide for your CSS. Just change the display to flex:
.row{
background-color: black;
border:1px solid white;
color:white;
display: flex;
flex-direction: row
padding:0;
}

Fixing column alignment

I want column 1 (comment 1) and column 2 (comment 2) to be next to each other and to be floated to the left side. Column 3 (comment 3) should be floated to the right side.
jsfiddle
I've tried a lot but can't make it work with %.
HTML:
<div class="comment_one">
<div class="reitings">
<div class="rate pluss"><img class="plus" alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAIAQMAAAD3KoyyAAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAAAtJREFUeNpjYMAOAAAYAAFG27MLAAAAAElFTkSuQmCC"> 83</div>
</div>
</div>
<div class="comment_two">
<div class="reitings">
<div class="rate minuss"><img class="minus" alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAIAQMAAAD3KoyyAAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAAAtJREFUeNpjYMAOAAAYAAFG27MLAAAAAElFTkSuQmCC"> 9</div>
</div>
</div>
<div class="comment_three">
<div class="reitings">
<div class="rate minuss"><img class="minus" alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAIAQMAAAD3KoyyAAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAAAtJREFUeNpjYMAOAAAYAAFG27MLAAAAAElFTkSuQmCC">Report</div>
</div>
</div>
CSS:
.comment_one {
width:25%;
float:left;
}
.comment_two {
width:25%;
float:left;
}
.comment_three {
float:right;
width:40%;
}
.reitings {
display:table;
width:50%;
border:1px solid #e9e9e9;
-webkit-border-radius:4px;
-moz-border-radius:4px;
border-radius:4px;
}
.rate {
display:table-cell;
text-align:center;
vertical-align:middle;
line-height:1.5em;
padding:10%;
}
.rate img {
vertical-align:middle
}
.pluss {
background:#f5f5f5;
color:#4d761a
}
.minuss {
background:#f5f5f5;
color:#a8404b;
border-left:1px solid #e9e9e9;
text-align:center
}
Structure the HTML:
<div id="comments">
<div class="c1 rate-plus"></div>
<div class="c2 rate-plus"></div>
<div class="c3 rate-minus"></div>
</div>
Access all divs in #comments with #comments div. Think about what the divs have in common. Write it in the CSS. For Example:
#comments div {
background: #f5f5f5;
border-left: 1px solid #e9e9e9;
padding: 12px;
margin: 5px;
text-align: center;
}
Float c1 and c2 with left and c3 with right.
Complete CSS
#comments div {
background: #f5f5f5;
border-left: 1px solid #e9e9e9;
padding: 12px;
margin: 5px;
text-align: center;
}
.rate-plus {
color: #4d761a
}
.rate-minus {
color: #a8404b;
}
.c1, .c2 {
width: 25%;
float: left;
}
.c3 {
width: 37%;
float: right;
}
Complete HTML
<div id="comments">
<div class="c1 rate-plus">
<img class="plus" alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAIAQMAAAD3KoyyAAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAAAtJREFUeNpjYMAOAAAYAAFG27MLAAAAAElFTkSuQmCC">83
</div>
<div class="c2 rate-minus">
<img class="minus" alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAIAQMAAAD3KoyyAAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAAAtJREFUeNpjYMAOAAAYAAFG27MLAAAAAElFTkSuQmCC">9
</div>
<div class="c3 rate-minus">
<img class="minus" alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAIAQMAAAD3KoyyAAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAAAtJREFUeNpjYMAOAAAYAAFG27MLAAAAAElFTkSuQmCC">Report
</div>
</div>
I've modified it a little bit.
Demo

Links not aligning inside the box as they are supposed to

I am building a website and right now I'm just about to complete the homepage. Now, the footer has a few links in it along with a few images next to each other like a contact us bar. But the links don't seem to align with the images even after trying everything. They seem to hang a little lower than the paragraphs or spans. I tried converting the spans on the same line to links but now all of them hang low.
HTML:
<div id="brdr_btm">
<div id="contactOptionContainer">
<div class="ctcObject">
<img class="ic_contact" src="http://i.imgur.com/pGiDhI2.png?1"/>
<div id="ctcLinks">
La Martiniere College, Lucknow
</div>
</div>
<div class="ctcObject">
<img class="ic_contact" src="http://i.imgur.com/E8Ow3O7.png?1">
<div id="ctcLinks">
secretariat#lmun.org
</div>
</div>
<div class="ctcObject">
<img class="ic_contact" id="ic_call" src="http://i.imgur.com/1di7mj9.png?1">
<!--<div id="phoneno">-->
<div id="ctcLinks">
+91 9670680417 (Sec. Gen), <!-- was span -->
+91 9415444444 (Dep. Sec. Gen) <!-- was span -->
</div>
</div>
<div class="ctcObject">
<img class="ic_contact" src="http://i.imgur.com/2HZVi1r.png?1">
</div>
</div>
</div>
CSS:
#brdr_btm
{
display:flex;
position:relative;
height: 25px;
width: 100%;
background-color: #70A5DA;
top:100%;
vertical-align:bottom;
margin_top:10px;
clear:both;
box-sizing:content-box;
/*z-index:-1;*/
}
#contactUs
{
margin:auto;
}
#contactOptionContainer
{
position:relative;
display:inline-block;
margin-top:auto;
margin-bottom:auto;
/* text-align:center;*/
box-sizing:content-box;
width:auto;
}
.ctcObject
{
display:inline-block;
margin-left:auto;
margin-right:5em;
/* margin-bottom:6px;*/
/* margin-top:auto;*/
}
.ic_contact
{
position:relative;
margin-top:6.25px;
margin-bottom:6.25px;
height: 12.5px;
width: 12.5px;
-webkit-user-drag:none;
user-select:none;
-ms-user-select:none;
-moz-user-select:none;
-webkit-user-select:none;
user-drag:none;
/* z-index:-1;*/
}
#ic_call
{
margin-top: -2px;
height:10.5px;
width:10.5px;
}
#ctcLinks
{
position:relative;
display:inline-block;
}
#ctcLinks a
{
position:relative;
margin-top:-6px;
margin-bottom:0px;
/* display:inline-block;*/
font-size:0.8em;
color:#FFFFFF;
/* text-align:center;*/
}
#phoneno
{
position:relative;
display:inline-block;
text-align:center;
}
#phoneno span
{
margin-left:0;
margin-right:0;
margin-bottom:6px;
margin-top: -1px;
text-align:center;
display:inline-block;
color:#ffffff;
vertical-align:middle;
font-size:0.9em;
}
How do I prevent this from happening and what causes it?
What might be the solution to the problem?
Here's my JSFiddle: http://jsfiddle.net/mfxefccz/
You should add to .ic_contact and #ctcLinks this style
display: inline-block;
height: 100%;
vertical-align: middle;
#brdr_btm
{
display:flex;
position:relative;
height: 25px;
width: 100%;
background-color: #70A5DA;
top:100%;
vertical-align:bottom;
margin_top:10px;
clear:both;
box-sizing:content-box;
/*z-index:-1;*/
}
#contactUs
{
margin:auto;
}
#contactOptionContainer
{
position:relative;
display:inline-block;
margin-top:auto;
margin-bottom:auto;
/* text-align:center;*/
box-sizing:content-box;
width:auto;
}
.ctcObject
{
display:inline-block;
margin-left:auto;
margin-right:5em;
/* margin-bottom:6px;*/
/* margin-top:auto;*/
}
.ic_contact
{
position:relative;
margin-top:6.25px;
margin-bottom:6.25px;
height: 12.5px;
width: 12.5px;
display: inline-block;
height: 100%;
vertical-align: middle;
-webkit-user-drag:none;
user-select:none;
-ms-user-select:none;
-moz-user-select:none;
-webkit-user-select:none;
user-drag:none;
/* z-index:-1;*/
}
#ic_call
{
margin-top: -2px;
height:10.5px;
width:10.5px;
}
#ctcLinks
{
position:relative;
display: inline-block;
height: 100%;
vertical-align: middle;
display:inline-block;
}
#ctcLinks a
{
position:relative;
margin-top:-6px;
margin-bottom:0px;
/* display:inline-block;*/
font-size:0.8em;
color:#FFFFFF;
/* text-align:center;*/
}
#phoneno
{
position:relative;
display:inline-block;
text-align:center;
}
#phoneno span
{
margin-left:0;
margin-right:0;
margin-bottom:6px;
margin-top: -1px;
text-align:center;
display:inline-block;
color:#ffffff;
vertical-align:middle;
font-size:0.9em;
}
<div id="brdr_btm">
<div id="contactOptionContainer">
<div class="ctcObject">
<img class="ic_contact" src="http://i.imgur.com/pGiDhI2.png?1"/>
<div id="ctcLinks">
La Martiniere College, Lucknow
</div>
</div>
<div class="ctcObject">
<img class="ic_contact" src="http://i.imgur.com/E8Ow3O7.png?1">
<div id="ctcLinks">
secretariat#lmun.org
</div>
</div>
<div class="ctcObject">
<img class="ic_contact" id="ic_call" src="http://i.imgur.com/1di7mj9.png?1">
<!--<div id="phoneno">-->
<div id="ctcLinks">
+91 9670680417 (Sec. Gen), <!-- was span -->
+91 9415444444 (Dep. Sec. Gen) <!-- was span -->
</div>
</div>
<div class="ctcObject">
<img class="ic_contact" src="http://i.imgur.com/2HZVi1r.png?1">
</div>
</div>
</div>
Here a demo.
So, displayed it like an inline-block, because display: inline-block; don't work with blocks. And give then a height: 100%. In this case in means 100% from a parent. So we always have an image or block in the vertical center.
You have set margins for .ic_contact. If you remove margin-bottom for .ic_contact, your images and links would align properly. see here
.ic_contact
{
position:relative;
margin-top:6.25px;
height: 12.5px;
width: 12.5px;
}

Resizable HTML Table using Divs on IE9 with some cells as images and othes extensible

I have a question regarding HTML tables. I created HTML table using Divs. Some cells contain images so they have fixed size. The bottom cell is resizable according to data filled in other box. So, I don't want to use absolute option in this solute. Here's my code:
<!DOCTYPE html>
<html>
<header>
<style type="text/css">
object
{
outline: none;
display:block;
}
html, body {
margin:0; padding:0;
height:100%;
}
.divTable
{
width: 135px;
height: 100%;
display: table;
float:left;
background-color:blue;
}
.newDiv{
position: relative;
left:135px;
height:100%;
width:100%;
display: block;
background-color:yellow;
border:1px solid #BBBDBF;
border-left:0px;
}
.divTableRow
{
width: 135px;
height: 30px;
display: table-row;
}
.divTableCell
{
width: 135px;
height: 30px;
background: white url('Images/bottom_up.png') 0 0 no-repeat;
display: table-cell;
text-align:center;
vertical-align:middle;
}
.divTableTopCell
{
width: 135px;
height: 30px;
background: white url('Images/top_up.png') 0 0 no-repeat;
display: table-cell;
text-align: center;
border-bottom:1px solid #848385;
vertical-align:middle;
}
.divTableBottomBox
{
position:relative;
width: 133px;
height: 100%;
background-color: #d0d2d3;
display: block;
border:1px solid #BBBDBF;
clear:both;
}
.divParent{
position: relative;
display:block;
min-height:700px;
min-width:700px;
}
</style>
</header>
<body>
<div class='divParent'>
<div class="divTable">
<div class="divTableRow">
<div id = 'accountDetails' class="divTableTopCell">
Account Details
</div>
</div>
<div class="divTableRow">
<div id = 'locations' class="divTableCell">
Locations
</div>
</div>
<div class="divTableRow">
<div id = 'users' class="divTableCell">
Users
</div>
</div>
<div class="divTableRow">
<div id = 'training' class="divTableCell">
Training
</div>
</div>
<div class="divTableRow">
<div id = 'contracts' class="divTableCell">
Contracts
</div>
</div>
<div class='divTableBottomBox'>
</div>
</div>
<div class='newDiv'>
Helllo <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
</div>
</div>
</body>
</html>
Any help would be appreciated.
By the looks of it, you are marking up tabular data. If you have tabular table, it is semantically correct to use an actual HTML table. You shouldn’t try to fake it with divs. They're less suited for the task and are semantically invalid.
Thank you for the response. I fixed it.
Here's the solution:
<!DOCTYPE html>
<html>
<header>
<style type="text/css">
object
{
outline: none;
display:block;
}
html, body {
margin:0; padding:0;
height:100%;
}
.divLeftContainer{
min-height:100%;
height:100%;
display:block;
background-color:red;
float:left;
}
.divTable
{
float:left;
width: 135px;
height: auto;
display: table;
background-color:blue;
}
.newDiv{
position: relative;
left:135px;
height:100%;
width:100%;
display: block;
background-color:yellow;
border:1px solid #BBBDBF;
border-left:0px;
}
.divTableRow
{
width: 135px;
height: 100%;
display: table-row;
border:0px;
}
.divTableCell
{
width: 135px;
height: 30px;
background: white url('Images/bottom_up.png') 0 0 no-repeat;
display: table-cell;
text-align:center;
vertical-align:middle;
}
.divTableTopCell
{
width: 135px;
height: 30px;
background: white url('Images/top_up.png') 0 0 no-repeat;
display: table-cell;
text-align: center;
border-bottom:1px solid #848385;
vertical-align:middle;
}
.divTableBottomBox
{
width: 133px;
display:block;
height:100%;
background-color: #d0d2d3;
border:1px solid #BBBDBF;
border-top:0px;
margin-bottom:0px;
bottom:0px;
}
.divParent{
position: relative;
display:block;
height:700px;
min-height:700px;
min-width:700px;
}
</style>
</header>
<body>
<div class='divParent'>
<div class='divLeftContainer'>
<div class="divTable">
<div class="divTableRow">
<div id = 'accountDetails' class="divTableTopCell">
Account Details
</div>
</div>
<div class="divTableRow">
<div id = 'locations' class="divTableCell">
Locations
</div>
</div>
<div class="divTableRow">
<div id = 'users' class="divTableCell">
Users
</div>
</div>
<div class="divTableRow">
<div id = 'training' class="divTableCell">
Training
</div>
</div>
<div class="divTableRow">
<div id = 'contracts' class="divTableCell">
Contracts
</div>
</div>
</div>
<div class='divTableBottomBox'>
</div>
</div>
<div class='newDiv'>
Helllo <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
</div>
</div>
</body>
</html>

Negative margins not zooming correctly in Chrome and FireFox

I have a tree viewer that stopped working correctly in August when Chrome 21 was released. When zooming out (90% and lower) the layout gets messed up. I think it has to do with the margin-left: -1px; not zooming correctly.
I created a bug https://code.google.com/p/chromium/issues/detail?id=142178&thanks=142178&ts=1344723455 but have had no response.
The issue doesn't occur in Safari, IE and chrome 20, and until recently it didn't occur in FireFox.
Any suggestions?
http://jsfiddle.net/reueljw/yWgLU/3/
To reproduce zoom out in Chrome or FireFox.
<style type="text/css">
.tree { float:left; display:block; position:relative; }
.viewer { margin-left:auto; margin-right:auto; font-size:0.6em; }
.node-top { position:relative; min-width:30px; margin-left:auto; margin-right:auto; }
.node-left { position:relative; min-width:30px; }
.node-right { position:relative; min-width:30px; }
.node-data { max-width:60px; margin-left:auto; margin-right:auto;text-align:center; clear:both; overflow:hidden; height:15px; }
.starter { width:49.9999%; min-height:10px; position:relative; float:left; }
.ender { margin-left: -1px; width: 49.9999%; min-height:10px; position:relative; float:left; }
.tail { border-right: 1px solid #ACE; width: 49.9999%; min-height:10px; position:relative; float:left;}
.tailend { margin-left: -1px; width: 49.9999%; min-height:10px; position:relative; float:left;}
.node-left .ender { border-left: 1px solid #ACE; border-top: 1px solid #ACE;}
.node-right .starter { border-right: 1px solid #ACE; border-top: 1px solid #ACE;}
.child .tail { border: none }
</style>
<div id="template-area" class="viewer" style="width: 70px; padding-top: 30px;">
<div id="1" class="tree " style="width: 70px;">
<div class="node-top">
<div class="starter"></div>
<div class="ender"></div>
<div class="node-data node node-open">
<p class="node-text">1</p>
</div>
<div class="tail"></div>
<div class="tailend"></div>
</div>
<div id="2" class="tree child " style="width: 35px;">
<div class="node-left">
<div class="starter">
</div>
<div class="ender"></div>
<div class="node-data node node-open">
<p class="node-text">2</p>
</div>
<div class="tail"></div>
<div class="tailend"></div>
</div>
</div>
<div id="3" class="tree child " style="width: 35px;">
<div class="node-right">
<div class="starter"></div>
<div class="ender"></div>
<div class="node-data node node-open">
<p class="node-text">3</p>
</div>
<div class="tail"></div>
<div class="tailend"></div>
</div>
</div></div></div>
</div>