I have the following HTML structure
Some text goes here
Dif
-
The simple one:
elements {
border-left: black solid 1px;
}
elements:nth-child(1) {
border-left: none;
}
讨论(0)
-
try to use
border-left:1px solid #color;
margin-left:2px;
and
border-right:1px solid #color;
margin-right:2px;
讨论(0)
-
I tried border on both divs, (right border on child-1 and left border on div-2, but this is not a good idea, because the line will appear thick where the two divs touch each other and then thin for the extended part.
That's a good way to go, actually. The final step, though, is to give the right div a negative left margin of 1px (assuming the border is 1px wide), so that the two borders overlap.
#child-1 {
width: 500px;
float: left;
border-right: 1px solid gray;
}
#child-2 {
width: 200px;
float: left;
border-left: 1px solid gray;
margin-left: -1px;
}
Another option is to use display: table
on the parent and then display: table-cell
on the columns, and then have a single border line between them.
讨论(0)
-
You could also give border-right: 1px solid #000;
only to your first div if this div is longer than second div and if second div is longer you could assign border-left: 1px solid #000;
only to your second div.
讨论(0)