Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
How to add image into a block?
Old 02-24-2009, 09:02 PM How to add image into a block?
Super Talker

Posts: 132
Trades: 0
How can I add or insert images into a div which would normally only take text? Also, how can I position both image and text in the block to suit my needs?
mikehende is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-24-2009, 09:14 PM Re: How to add image into a block?
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Images are inline elements. This means they can be placed anywhere (like inside a paragraph), and they won't create line breaks. If you want to position them, it is sometimes helpful to make them block elements. You can do this by setting the display property in the CSS document.

Let's say we want a certain class of image to be a centered block element. We could do this:

HTML Code:
<img src="image/whatever.jpg" alt="whatever" class="centered" />
CSS
Code:
img.centered {
     display: block;
     margin: 0 auto;
}
Once you make an image a block-level element it can take on margins in a "normal" way.

Another thing you could do is use images as backgrounds instead of with the <img> tag. Background images can be positioned with %percentages or semantically (top, left center), or with px, or em.
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 02-25-2009, 10:33 AM Re: How to add image into a block?
LadynRed's Avatar
Defies a Status

Posts: 10,016
Location: Tennessee
Trades: 0
Quote:
How can I add or insert images into a div which would normally only take text?
Divs can contain anything, not just text.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How to add image into a block?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.12380 seconds with 12 queries