TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-08-2008, 10:58 PM   #1 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
Alan @ CIT is on a distinguished road
Default CSS Padding / Textarea problems

Hi all,

I'm having some problems using a textarea inside a div that has padding set.

I have the following in my CSS:

CSS Code:
#content {
padding: 0 40px 0 40px;
}

All page content is then wrapped in <div id="content"> to give some space at either edge of the page.

Unfortunately, this also effects textareas:

css-padding-textarea-problems-textarea_padding.png

Can any of you CSS experts clue me in on how to stop the textarea using the padding please?

Thanks,
Alan
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote
Old 03-08-2008, 11:17 PM   #2 (permalink)
The Acquainted
 
Gareth's Avatar
 
Join Date: Jan 2008
Posts: 136
Thanks: 4
Gareth is on a distinguished road
Default

You can target the textareas directly by adding a class, or indirectly by referring to all text areas in the content div or by all textareas and reset their padding.

Code:
#content textarea {
padding: 0;
}

OR

textarea {
padding: 0;
}
OR

Code:
<style type="text/css">
.example {
padding: 0;
}
</style>

<textarea class="example" rows="10" cols="10">example text</textarea>
Hope this helps :)
Gareth is offline  
Reply With Quote
The Following User Says Thank You to Gareth For This Useful Post:
Alan @ CIT (03-08-2008)
Old 03-08-2008, 11:25 PM   #3 (permalink)
The Contributor
 
DeMo's Avatar
 
Join Date: Jan 2008
Location: Brazil
Posts: 77
Thanks: 14
DeMo is on a distinguished road
Default

I tried to reproduce it here with a simple page but had no luck at all. Tested on Opera 9.26, Firefox 2.0.0.12 and IE7, all of them worked.

HTML Code:
<html>
<head>
<title>Untitled Document</title>
<style type="text/css">
#content {
	padding: 0 40px 0 40px;
}
</style>
</head>

<body>
<div id="content">
  <textarea>test</textarea>
</div>
</body>
</html>
I even tried using padding: inherit; for the textarea style but it had no effect. Maybe you can correct it with padding: 0 in the textarea style?
Send a message via ICQ to DeMo Send a message via MSN to DeMo Send a message via Skype™ to DeMo
DeMo is offline  
Reply With Quote
Old 03-08-2008, 11:27 PM   #4 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
Alan @ CIT is on a distinguished road
Default

Thanks Gareth, I used your first suggestion and it works great

Alan
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote
Old 03-08-2008, 11:28 PM   #5 (permalink)
The Acquainted
 
Gareth's Avatar
 
Join Date: Jan 2008
Posts: 136
Thanks: 4
Gareth is on a distinguished road
Default

Glad to have helped! (For once! normally it is my asking for help :P)

Edit:

Quote:
Originally Posted by DeMo View Post
I tried to reproduce it here with a simple page but had no luck at all. Tested on Opera 9.26, Firefox 2.0.0.12 and IE7, all of them worked.

HTML Code:
<html>
<head>
<title>Untitled Document</title>
<style type="text/css">
#content {
	padding: 0 40px 0 40px;
}
</style>
</head>

<body>
<div id="content">
  <textarea>test</textarea>
</div>
</body>
</html>
I even tried using padding: inherit; for the textarea style but it had no effect. Maybe you can correct it with padding: 0 in the textarea style?
We were not given the complete css stylesheet but it is quite possible Alan had indirectly given it padding (e.g. in a higher level). What my suggestion did was to reset all padding for that specific textarea.

Gareth
Gareth is offline  
Reply With Quote
Old 03-09-2008, 07:58 PM   #6 (permalink)
The Addict
 
Join Date: Nov 2007
Posts: 264
Thanks: 2
TlcAndres is on a distinguished road
Default

That Gareth is the sign of progress - of student to master :D
__________________
"What everyone seems to forget is that while knowledge certainly is something - it's the implementation of knowledge that brings power" - Andres Galindo.
TlcAndres is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 07:18 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design