These forums are currently read-only due to receiving more spam than actual discussion. Sorry.

It is currently Sat Dec 02, 2017 4:13 pm Advanced search

CSS Padding

If you are stuck or have questions regarding HTML or other Web technologies, ask your questions here. No question too dumb!

CSS Padding

Postby sgoldmn » Sat Apr 13, 2013 7:03 pm

I have a box thats 400px wide. There needs to be 30px padding for the text within that box but there is also a 400px wide image within the box. How can I make the padding not affect the image? Right now it is pushing the image out 30px
sgoldmn
<h6>
 
Posts: 1
Joined: Sat Apr 13, 2013 7:00 pm

Re: CSS Padding

Postby JAB Creations » Sat Apr 13, 2013 7:51 pm

You don't want padding, you want margin and you don't want it on the parent you want it on the child. This is a traditional CSS level 1 problem that a lot of people have trouble with.

Padding and margin have different effects on elements. Add the margin to the image, remember it can be negative (on either side) and thus not add to the total width of the parent element.

For a more insightful answer you'd want to reply with the relevant HTML (not the whole page) and CSS.
User avatar
JAB Creations
<aside>
 
Posts: 566
Joined: Tue Mar 13, 2007 4:48 am
Location: Sarasota Florida, USA

Re: CSS Padding

Postby zcorpan » Mon Apr 15, 2013 2:49 pm

Quick fix would be a -30px left margin on the image.
zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden

Re: CSS Padding

Postby ManyMM » Mon Dec 02, 2013 6:52 pm

Negative margin values aren't always a good thing. E.g. Inline-styled HTML pages that are created for on-line web auction templates and some content management systems templates quite often ignore negative margins while going through parsing.
ManyMM
<h6>
 
Posts: 3
Joined: Mon Dec 02, 2013 6:45 pm

Re: CSS Padding

Postby JAB Creations » Mon Dec 02, 2013 10:39 pm

ManyMM wrote:some content management systems templates quite often ignore negative margins while going through parsing.


You're talking about poor web software not browsers, that doesn't apply to any situation except for someone who needs to stop using such software.
User avatar
JAB Creations
<aside>
 
Posts: 566
Joined: Tue Mar 13, 2007 4:48 am
Location: Sarasota Florida, USA

Re: CSS Padding

Postby ManyMM » Tue Dec 10, 2013 3:35 pm

IE is also "poor" software and you still have to make everything up and going for IE.
ManyMM
<h6>
 
Posts: 3
Joined: Mon Dec 02, 2013 6:45 pm


Return to Help & Advice

Who is online

Users browsing this forum: No registered users and 0 guests