I’m working on a news feed and I faced the following:
I want to clear all items under the avatar, so there is no wrapped text or anything below.
This image shows the issue:
I want it to be like this (made it with Photoshop):
The code:
.news .news-item .avatar {
background-image: url("https://dl.dropboxusercontent.com/u/35853519/zakzek.png");
width: 55px;
height: 55px;
background-size: cover;
float: right;
margin-left: 15px;
display: block;
}
JSFiddle (see full screen for better view):
http://jsfiddle.net/shadeed9/6npjgt7y/8/
Thanks,
5
Answers
DEMO
Add margin
DEMO
or add padding
or use transform
Without altering the structure of the HTML, one way to achieve that is to add a margin on the meta content div with CSS. Like so:
That will move everything to the left. Just make the margin larger than your avatar image width and there won’t be any wrapping.
Giving the avatar and the h2 element the property
display: inline-block
will do the trick, also set anwidth
for the h2 element.http://jsfiddle.net/6npjgt7y/9/
You can use a table, put the avatar in one column and your other contents in second column, like this:
If it is about dealing with float, then the
overflow:hidden;
rule is fine.It shows element where float elements are standing as much inside than aside and earlier in the flow of the document.
http://jsfiddle.net/6npjgt7y/14/
It’s about layout 🙂
So does trigger it as well :
display:table
/inline-block
/flex
and so doesfloat
.