473,804 Members | 3,211 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

padding-left, padding-right..

hi,

I recently discovered the hard way that when you had padding-right or
padding-left to a div it increases the with of the div... how do you
add left-padding or right-padding to a div w/o changing the width of it?

(for example: I have a div that's 320px wide, content inside is 300px
and I added padding-left:10px but it increased with of div to 330px.. I
want width of it to remain 320px but I need a padding on the left of 10px..)

thank you..
Mar 31 '08 #1
6 4713
maya wrote:
hi,

I recently discovered the hard way that when you had padding-right or
padding-left to a div it increases the with of the div... how do you
add left-padding or right-padding to a div w/o changing the width of it?

(for example: I have a div that's 320px wide, content inside is 300px
and I added padding-left:10px but it increased with of div to 330px.. I
want width of it to remain 320px but I need a padding on the left of
10px..)

thank you..

I vaguely recall something from school - I think it was called
"arithmetic " :-)

<div style="width: 300px; padding: 10px"></div>

300 + 2 * 10 = 320
All kidding aside, if for some reason you can't just subtract the
padding from the width of the box (i.e. if you're using different units
for the width and the padding) then you can just add a second box inside
the first, with no defined width and the padding you want:

<div style="width: 60%">
<div style="padding: 2em">
<p>Content</p>
</div>
</div>
Note: inline styles are for easy demonstration purposes. You shouldn't
actually use them.

Jeremy
Mar 31 '08 #2
In article <47********@new s.x-privat.org>, maya <ma********@yah oo.com>
wrote:
hi,

I recently discovered the hard way that when you had padding-right or
padding-left to a div it increases the with of the div... how do you
add left-padding or right-padding to a div w/o changing the width of it?

(for example: I have a div that's 320px wide, content inside is 300px
and I added padding-left:10px but it increased with of div to 330px.. I
want width of it to remain 320px but I need a padding on the left of 10px..)

thank you..
Would this example help you:

<http://netweaver.com.a u/alt/widthPadding.ht ml>

(the padding left is exaggerated to demonstrate. The url will not be for
the world long.)

--
dorayme
Mar 31 '08 #3
In article <Qs************ *************** ***@earthlink.c om>,
Jeff <jeff@spam_me_n ot.comwrote:
dorayme wrote:
In article <47********@new s.x-privat.org>, maya <ma********@yah oo.com>
wrote:
hi,

I recently discovered the hard way that when you had padding-right or
padding-left to a div it increases the with of the div... how do you
add left-padding or right-padding to a div w/o changing the width of it?

(for example: I have a div that's 320px wide, content inside is 300px
and I added padding-left:10px but it increased with of div to 330px.. I
want width of it to remain 320px but I need a padding on the left of
10px..)

thank you..
Would this example help you:

<http://netweaver.com.a u/alt/widthPadding.ht ml>

(the padding left is exaggerated to demonstrate. The url will not be for
the world long.)


I think it's been a while since Dorayme wrote that, as she would not
use a transitional doc-type now!
Well, "she" (and much more correctly "it") should have been changed by
me to Strict and it - no, not me! the other it, the html doc it - is now
Strict. So thanks Jeff.

I just grab whatever html file is lying around and throw something in it
that is to some current need. On this occasion, I seemed to have grabbed
something old or something used to discuss some difference between
strict and not strict. <g>

--
dorayme
Apr 1 '08 #4
In article
<do************ *************** *******@news-vip.optusnet.co m.au>,
dorayme <do************ @optusnet.com.a uwrote:
Well, "she" (and much more correctly "it") should have been changed by
me to Strict and it - no, not me! the other it, the html doc it - is now
Strict. So thanks Jeff.
should really read

Well, "she" (and much more correctly "it") should have changed it - no,
not me! the other it, the html doc it. It is now Strict. So thanks Jeff.

--
dorayme
Apr 1 '08 #5
dorayme wrote:
In article
<do************ *************** *******@news-vip.optusnet.co m.au>,
dorayme <do************ @optusnet.com.a uwrote:
>Well, "she" (and much more correctly "it") should have been changed by
me to Strict and it - no, not me! the other it, the html doc it - is now
Strict. So thanks Jeff.

should really read

Well, "she" (and much more correctly "it") should have changed it - no,
not me! the other it, the html doc it. It is now Strict. So thanks Jeff.
I see....:) thank you all very much for your responses...
Apr 3 '08 #6
dorayme wrote:
In article
<do************ *************** *******@news-vip.optusnet.co m.au>,
dorayme <do************ @optusnet.com.a uwrote:
>Well, "she" (and much more correctly "it") should have been changed by
me to Strict and it - no, not me! the other it, the html doc it - is now
Strict. So thanks Jeff.

should really read

Well, "she" (and much more correctly "it") should have changed it - no,
not me! the other it, the html doc it. It is now Strict. So thanks Jeff.
Hmm, I don't think we've discussed the gender of html docs before.
Although I can certainly understand the confusion behind what gender a
transitional page is!

Jeff
>
Apr 3 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1630
by: MichaelY | last post by:
Anyone figure out a workaround for setting the width on labels in 2.0??? I know width is no longer a valid property on inline text elements (per W3C), so what are the other options??? I have many valid uses for setting an explicit width on a label...and no, I do not want to switch back into Quirks mode just to get it to work. TIA, mike
6
1479
by: Chris Botha | last post by:
I am porting an existing 2003 project to 2005. Yesterday I found that some of my Java script did not want to work. After eventually examining the HTML view of the new and old form for differences, I noticed the DOCTYPE lines pretty close to the top of the forms in HTML view differ. I removed the line in the new form and my Java script worked. Today I noticed that a SPAN on a new form with the width property set to 100% displayed about 1/4...
5
5297
by: gimme_this_gimme_that | last post by:
I'd like to create my own version of google suggest GS. If you haven't seen GS check it out at : http://www.google.com/webhp?complete=1&hl=en I've reviewed several AJAX write-ups on the internet and understand the issues around passing and fetching data from the client to the server. Well, at least as it's described in various tutorials.
3
1484
by: Roy Reed | last post by:
I found a script that converts image alt text to a caption which I've tried to modify for my needs: function addCaption(imgElem) { var captionElem = document.createElement("div"); captionElem.className = "caption"; var captionText = document.createTextNode(imgElem.alt); captionElem.appendChild(captionText); if(imgElem.nextSibling) imgElem.parentNode.insertBefore(captionElem,imgElem.nextSibling);
6
2316
ak1dnar
by: ak1dnar | last post by:
Hi, I am developing a web site that displays Products, and along with each products there is a Button.There is a <DIV> in my page to display Number of Products Added to the Basket. Items : 0 When user comes to the page, items will display as 0. if click the Button along with the product items will set to 1. Again user can click product only one time. Like wise for each and every onclick my Ajax function will fire. This is how it works:...
2
13908
by: jmatos | last post by:
I need to change the style of an element changing its padding-left property (got it in firefox but IE is a different battle..). I can use document.getElementById().style.XX to everything i need, except with padding-left, as it is separated by a ' - ' and it is not correct to use it as it was supposed to: document.getElementById('el').style.padding-left = '5px' will throw 'invalid assignment left-hand side', as expected.. Any help...
3
8653
by: suganya | last post by:
Hi Some professionals already has developed the project using menu. In my company, they have given me task to clear the error in that. It is a script file named as "menubarAPI4.js" which is kept inside the folder "menu_script". The following is the code in this file. var menuOffsetTop=menuOffsetLeft=submenuOffsetTop=submenuOffsetLeft=submenuOffsetRight=0; var Doc=this.document;var standards=Doc.createElement&&Doc.createTextNode?1:0;...
1
9493
by: gandhi.vishal | last post by:
Hello, I have an issue. I'm not seeing the reportviewer data at all. The column names come up fine but there is no data in the report table. Here is what I'm doing I created a dataset with the following query select * from av_project_mst where apm_project_id=@projectid Now I created a report (.rdlc) and dragged a table onto it and the report looks like the following
6
1762
Claus Mygind
by: Claus Mygind | last post by:
I would like for the two child nodes in the code below to appear side by side. But in all my attempts they are stacked on top of each other. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <SCRIPT LANGUAGE="JavaScript"> <!-- // Create a div to hold the control. var controlDiv = document.createElement('DIV');
0
9707
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9585
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10586
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7622
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5658
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.