B
B
Baxterok2015-10-16 13:48:22
css
Baxterok, 2015-10-16 13:48:22

How to make 2 divs on one line?

I know there are 3 ways:

  • Use display: inline-block
  • Use float: left/right
  • Use position: absolute

In the first block I have the main content, and the second block is the sidebar. You need to set a background for the sidebar. The background should be the entire length of the parent block, regardless of whether the content or the sidebar sets this length.
position: absolute - not suitable, as there is a fixed height.
float: left/right - not suitable, because when setting the height to height: 100%, only the constant height of the parent is inherited.
display: inline-block - here I can't even set it on the same line with constant latitude values ​​( jsfiddle ).

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vadim Bogomazov, 2015-10-16
@Baxterok

?

L
Lenar Fattakhov, 2015-10-16
@fr_end

jsfiddle.net/65p1c1t2/1
set font-size 0 to the parent block
read about spaces in inline block elements

D
dk-web, 2015-10-16
@dk-web

codepen.io/anon/pen/bdOWze?editors=110
did not go deep, but once this link saved me

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question