Current location: Hot Scripts Forums » General Web Coding » CSS » CSS Border Width Question.


CSS Border Width Question.

Reply
  #1 (permalink)  
Old 09-06-06, 10:44 AM
nova912's Avatar
nova912 nova912 is offline
Code Guru
 
Join Date: Sep 2004
Location: Traverse City, MI, USA
Posts: 821
Thanks: 0
Thanked 0 Times in 0 Posts
CSS Border Width Question.

How do i make a border wrap around text keeping a padding of 5px (or any other style for the matter).

I could do this a dirty way and make a table with 1 cell and then put the text between <nobr>this and it would stay on one line</nobr> but there must be a better way of controling the environment.

Right now the border width just goes untill it hits a wall.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 09-06-06, 12:08 PM
JonnyBee JonnyBee is offline
New Member
 
Join Date: Sep 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Not 100% sure what you mean but I'll have a Go..

//css sheet
Code:
#somediv //Add what ever Styling you want here
{
margin-left:auto;
margin-right:auto;
position:relative;
}

#somediv p //note that the P indicates that it will only effect content between <p> tags t
{
display:block;
padding: 5px;
border:Solid 1px #000000;
float:left;
}
//Html

Code:
<div id="somediv">
<p>some text here</p>
</div>
I thinks thats the sort of thing your after..

Last edited by Christian; 09-06-06 at 04:14 PM. Reason: Please use [code] wrappers when posting code.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 09-06-06, 01:27 PM
nova912's Avatar
nova912 nova912 is offline
Code Guru
 
Join Date: Sep 2004
Location: Traverse City, MI, USA
Posts: 821
Thanks: 0
Thanked 0 Times in 0 Posts
what i mean is this

with this code the border will look like this
----------------------------...
|blah blah
----------------------------...
.. all the way to the end of the element that the div is in, how do i make it like this...
------------
|blah blah|
------------
Code:
<div style="border:1px solid red"><font>blah blah</font></div>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 09-06-06, 02:33 PM
Spaced Spaced is offline
Newbie Coder
 
Join Date: Jul 2006
Location: Winnipeg MB
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Code:
CSS:
(if you want the border on all your paragraphs)
p{margin: 2px; padding: 5px; border: 1px solid #000;}

(If you wants them only on certain paragraphs)
.yourclassname{margin: 2px; padding: 5px; border: 1px solid #000;}

-----

HTML:

<p class="yourclassname">hello world</p>
get rid of the <font> tags, you do not need them. Use <p> (paragraph) tags when you are coding any sort of text.

I gave it a margin of 2px just for a little bit of spacing around the text, you can change that.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 09-06-06, 02:44 PM
JonnyBee JonnyBee is offline
New Member
 
Join Date: Sep 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Ahh Inline Css .. And just top and bottom.. gotcha!

Code:
<div style="border-top:1px solid red; border-bottom:1px solid red"><p>Some Text</p></div>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 09-06-06, 04:12 PM
nova912's Avatar
nova912 nova912 is offline
Code Guru
 
Join Date: Sep 2004
Location: Traverse City, MI, USA
Posts: 821
Thanks: 0
Thanked 0 Times in 0 Posts
Well the problem is, the text may be only as long as "Invalid E-Mail Address" its never going to be longer then that.

I could solve this by going like so and the table would start out as only 1px wide but the <nobr> will actually strech out the same to the width of the text AND the <div>'s style will also strath out the table.
Code:
<table width="1">
<tr>
<td>
<div class="style1">
<nobr>E-Mail Invalid.</nobr>
</div>
</td>
</tr>
</table>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 09-07-06, 10:13 AM
Spaced Spaced is offline
Newbie Coder
 
Join Date: Jul 2006
Location: Winnipeg MB
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
I forgot one part of this.
With the float on <p> tag the border will go only the length of the text. The "clearyourclass" class is to push any text that is suppose to be underneath "yourclassname" you can do this with a <br clear="all" /> but you have less control of the final product.
Code:
CSS:
.clearyourclass{width: 100%; float: left;}
.yourclassname{margin: 2px; padding: 5px; border: 1px solid #000; float: left; clear: both;}

-----------
<div class="clearyourclass">
     <p class="yourclassname">Your text Here</p>
</div>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript Controlling CSS Question nova912 JavaScript 4 04-26-09 08:45 AM
CSS border problem in firefox, looks good in IE vertigoflow CSS 1 02-18-06 11:30 AM
CSS Border problem in FireFox mani786 CSS 1 10-01-05 08:33 AM
CSS Question Justin171985 CSS 1 06-04-05 05:00 AM
table border question timmy long HTML/XHTML/XML 5 05-23-05 10:36 AM


All times are GMT -5. The time now is 06:37 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.