0

i want make two icons together side by side

My html code

<head>
<style>
.icon_one{
 width:25px;
 height: 20px;
 background:#ffffff url('icon_one.jpg') no-repeat right top;
}
.icon_two{
 width:25px;
 height: 20px;
 background:#ffffff url('icon_two.jpg') no-repeat right top;
}
</style>
</head>
<div class="icons"><div class="icon_one"></div><div class="icon_two"></div></div>

i want show them side by side

example :

icone1|icone2

but the code output

icond1

icone2

Thank you

asked Sep 12, 2011 at 17:51

5 Answers 5

1

Just add

.icon_one, .icon_two{display:inline-block;}

Live Demo

Then you wont have to worry about clearing floats later.

Otherwise you can use floats,

.icon_one, .icon_two{float:left;}

Demo with floats

answered Sep 12, 2011 at 17:53
Sign up to request clarification or add additional context in comments.

Comments

0

Add a float to your elements...

.icon_one, .icon_two {
 float: left;
}
answered Sep 12, 2011 at 17:52

Comments

0

add float:left to each icon class so they float next to each other, dont forget to add some margin space in between.

answered Sep 12, 2011 at 17:53

Comments

0

You can also change the div's to spans instead.

<div class="icons">
 <span class="icon_one"></span>
 <span class="icon_two"></span>
</div>
answered Sep 12, 2011 at 17:56

Comments

0

You can either float:left; each div or set each div to display:inline-block;

So Example 1:

.icon_one, .icon_two{
 width:25px;
 height: 20px;
 background:red url('icon_one.jpg') no-repeat right top;
 display:inline-block;
}
.icon_two{
 background:blue url('icon_two.jpg') no-repeat right top;
}

http://jsfiddle.net/jasongennaro/YESWV/1/

NB: You can actually trim down your code, as above.

Also, I changed the background-color so it was easier to see the example.

Example 2:

.icon_one, .icon_two{
 width:25px;
 height: 20px;
 background:red url('icon_one.jpg') no-repeat right top;
 float:left;
}
.icon_two{
 background:blue url('icon_two.jpg') no-repeat right top;
}

http://jsfiddle.net/jasongennaro/YESWV/2/

answered Sep 12, 2011 at 17:53

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.