.html
<div class="container">
<div class="col1">
col1
</div>
<div class="col2">
col2
</div>
</div>
Assuming that there is an HTML markup like the above, I suggest the following two methods.
Solution 1 : How to use Flexbox
https://jsfiddle.net/qy3rmn9w/1/
.container {
display: flex;
}
.col1 {
flex-grow: 3;
background-color: gray;
}
.col2 {
flex-grow: 2;
background-color: lightgray;
}
Solution 2 : How to use the table
https://jsfiddle.net/4xa2o39q/
.container {
display: table;
width: 100%;
}
.col1 {
display: table-cell;
width: 60%;
background-color: gray;
}
.col2 {
display: table-cell;
background-color: lightgray;
}
http://hashcode.co.kr/questions/1689
If you look at the answer, there is a similar code, so I hope you can refer to it.
Why don't you try css as follows?
.table {
position: relative;
width: 100%;
/* Next, for convenience, add more */
height: 200px;
}
.col1 {
display: inline-block;
width: 60%;
/* Next, for convenience, add more */
height: 100%;
background-color: yellow; /* Yellow background*/
}
.col2 {
display: inline-block;
position: absolute;
left: 60%; /* from left 60% */
right: 0; /* to the right */
/* Next, for convenience, add more */
height: 100%;
background-color: cyan; /* yellow background*/
}
And I think HTML should be done as follows.
<div class="table">
<div class="col1">Left 60%</div>
<div class="col2">Remaining right</div>
</div>
I'm not sure what you want.
© 2024 OneMinuteCode. All rights reserved.