The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
Dev Shed Forums
> Web Design
> CSS Help
Shorter border, is it possible?
Discuss Shorter border, is it possible? in the CSS Help forum on Dev Shed. Shorter border, is it possible? Cascading Style Sheets (CSS) forum discussing all levels of CSS, including CSS1, CSS2 and CSS Positioning. CSS provides a robust way of applying standardized design concepts to your web pages.
Dev Shed Forums Sponsor:
May 25th, 2006, 04:19 AM
Registered User
Join Date: May 2006
Posts: 6
Time spent in forums: 5 h 30 m 45 sec
Reputation Power: 0
Shorter border, is it possible?
Hiho,
I want to style my heading with a top and bottom boarder. A simple solid one works pretty fine. But I like to have one that is padden padded at the left and at the right. Is there a way to do it?
Here is my code:
Code:
#content1 h2
{ padding-left: 10px;
padding-right: 10px;
clear:both;
position: inherit;
color: #86BDF5;
border-top: solid 3px #336699;
border-bottom: solid 3px #336699;
font-size:1.2em;
font-family: Lucida sans, Verdana, sans-serif;
}
I just want the the border to be padded also. ...i searched a lot, but i find no solution.
greetz,
ratsche
May 25th, 2006, 05:35 AM
|<.+#f@#+.&.|
Join Date: Mar 2002
Location: norway
If I've understood you correct you want to use margin instead of left and right padding.
Code:
#content1 h2
{ margin -left: 10px;
margin -right: 10px;
clear:both;
position: inherit;
color: #86BDF5;
border-top: solid 3px #336699;
border-bottom: solid 3px #336699;
font-size:1.2em;
font-family: Lucida sans, Verdana, sans-serif;
}
If you look at the box model, you can see that the border is outside of the padding but within the margins of an element.
http://www.w3.org/TR/CSS21/box.html#box-dimensions
__________________
May 25th, 2006, 06:13 AM
Anal Purist
Join Date: Jun 2005
Location: Bob's Auto Parts...
I think ratsche wants something like this:
Code:
------
THE HEADER
------
Though, I haven't given it enough thought to come up with a solution yet.
The trouble is, it defies the nature of the box model - there'll need to be some dark CSS witchery involved
__________________
We are troll foldy-rolls and we'll eat you for our supper.
Last edited by Grafmix : May 25th, 2006 at 06:16 AM .
May 25th, 2006, 07:05 AM
Cunning Linguist
Join Date: Jul 2003
Location: I used to live at home, now I stay at the house
How bout something like:
Code:
<style type="text/CSS">
#content1 h2
{
display:inline;
margin:0px 10px 0px 10px;
position: inherit;
color: #86BDF5;
border-top: solid 3px #336699;
border-bottom: solid 3px #336699;
font-size:1.2em;
font-family: Lucida sans, Verdana, sans-serif;
}
#content1 h2 span
{
margin:0px -10px 0px -10px;
}
</style>
</head>
<body>
<div id="content1">
<h2><span>The Header</span></h2>
<p>Lorem ispum..</p>
</div>
</body>
</html>
?
Comments on this post
Grafmix
agrees: Ruddy bloody nice one!
kk5st
agrees: Rats! You always grab the easy ones.
Nice hack.
May 30th, 2006, 04:10 AM
Registered User
Join Date: May 2006
Posts: 6
Time spent in forums: 5 h 30 m 45 sec
Reputation Power: 0
thx a lot! that's what I'm looking for!
...looks easy, if you know how to do it
greetz,
ratsche
Developer Shed Advertisers and Affiliates
Thread Tools
Search this Thread
Display Modes
Rate This Thread
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off