Reputation: 13585
HTML is
<div class="jfmfs-friend-container">
<div class="jfmfs-friend ">
<input class="friend-checkbox" type="checkbox">
<img src="/picture">
<div class="friend-name">Test User</div>
</div>
</div>
Here I am able to achieve all three elements checkbox, img and friend-name div
in a single line. I am looking for following:
Here is my CSS. I am giving css code for the parent div incase of any display:block property:
.jfmfs-friend div {
color:#111111;
font-size:11px;
overflow:hidden;
display:inline-block;
}
div.friend-name {
margin-left: 10px;
vertical-align: middle;
word-wrap: break-word;
}
.friend-checkbox {
position: relative;
vertical-align:middle;
display: inline-block;
}
#jfmfs-friend-container {
overflow:scroll;
overflow-x: hidden;
-ms-overflow-x: hidden;
width:100%;
height:400px;
font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;
color: #333;
font-size: 12px;
}
Upvotes: 1
Views: 3260
Reputation: 1264
To center your elements in the "jfmfs-friend" div, you need to add this css:
div.jfmfs-friend {
text-align: center;
}
To make the word-wrap in your "friend-name", you need to set the width. Currently it will expand to the size of it's parent. Setting the width of the "friend-name" dive or one of it's parent containers will cause the text to break when it meets the edge of the element.
To get your elements to be separated from eachother, you need to play with the padding and margin css properties until you get the desired effect. Adding a padding of 5px to each element would probably do what you want.
.friend-checkbox, img, .friend-name {
padding: 5px;
}
You can use jsfiddle.net to tweak your layout and get a live preview. This will help you get the spacing you desire.
Also, check out these references on the padding and margin properties.
Upvotes: 0
Reputation: 2624
Demo: http://jsfiddle.net/55twK/
vertical-align:middle
to all three elements, now you miss img.Upvotes: 2