Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-04-2012, 03:21 AM   PM User | #1
green_meep
New Coder

 
Join Date: Sep 2012
Posts: 14
Thanks: 1
Thanked 0 Times in 0 Posts
green_meep is an unknown quantity at this point
Alternative to divs with background-image set?

Hey all,

I'm trying to insert symbols on a webpage, sort of like how various card games do it. The problem is that I want to write letters/numbers on them as well.

I've gotten the main code working with <div> tags, but the problem with using <div> tags is that like one would expect, it tends to force a break. Is there any other way I can do things?

Thanks in advance.
green_meep is offline   Reply With Quote
Old 10-04-2012, 02:12 PM   PM User | #2
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,498
Thanks: 18
Thanked 361 Times in 360 Posts
sunfighter is on a distinguished road
div {
display: inline;
} should remove that effect. floats also work.
sunfighter is offline   Reply With Quote
Old 10-04-2012, 09:00 PM   PM User | #3
green_meep
New Coder

 
Join Date: Sep 2012
Posts: 14
Thanks: 1
Thanked 0 Times in 0 Posts
green_meep is an unknown quantity at this point
Thanks for your response.

I was reading that it's not recommended to override this standard behavior of <div>s, and should instead use <span>s. However, it doesn't matter between inline <div>s and <span>s, because when I switch, it seems to not display anything at all, whether I have height/width explicitly set or not.
green_meep is offline   Reply With Quote
Old 10-04-2012, 10:48 PM   PM User | #4
Basscyst
Smokes a Lot


 
Join Date: Jul 2003
Location: CA, USA
Posts: 1,594
Thanks: 5
Thanked 20 Times in 20 Posts
Basscyst is on a distinguished road
Inline elements don't have a set height and width, they just fill to the content, so if you have nothing in the inline element it never gets large enough to display the background image.

Just set float:left

I'd suggest putting all your floated divs in a container div also set to float:left;

Then if you have any content further down the page, you'll put it in a container with clear:left;

This will ensure that the container of your floated elements maintain its place in the dom and allow you to properly adjust its margins.
__________________
Helping to build a bigger box. - Adam Matthews

Last edited by Basscyst; 10-04-2012 at 10:56 PM..
Basscyst is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:34 AM.


Advertisement
Log in to turn off these ads.