i’m getting an error message that the inline-block is ignored due to the float. what does this mean and what should i revise within my code? does this affect anything?
.sidebar-left {
width: 175px;
float: left;
}
.sidebar-right {
width: 155px;
float: right;
display: inline-block;
}
.main {
width: 530px;
margin-left: 10px;
float: left;
}
I’m trying to make 3 responsive boxes within rows, with each of the boxes coming one right after another with the box order not changing. My other boxes (‘sidebar-left’ and ‘main’) seem to be working fine though. The error message is popping up on the ‘sidebar-right’ code.
2
Answers
Point 1
when you use
float
on the element, the display property of the element must be eitherblock
,grid
,flex
ortable
.If you set the display property to
inline-xxx
, it will be automatically converted/computed toblock
or block equivalent (such asinline-grid
=>grid
).So, in your case,
.sidebar-right
element is automatically gettingdisplay: block
property and your codedisplay: inline-block;
is being ignored.more info
Point 2
You can use
flexbox
orgrid
As for responsiveness, you can change the number of columns and column width on
grid-template-columns: 175px 530px 155px;
line as you like.inline-block
is ignored due to thefloat
. Iffloat
has a value other thannone
, the box is floated anddisplay
is treated asblock
.Take a look at this article: https://vanseodesign.com/css/inline-blocks/