Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > CSS > CSS Cascading Style Sheets
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
CSS Cascading Style Sheets All issues relating to Cascading Style Sheets (CSS).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the CSS Cascading Style Sheets section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 9th, 2007, 10:35 PM
Registered User
Join Date: Jan 2005
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts

I have created a css button like title.The code is listed below. But I want the title background to grow as the text expands instead of a fixed width. I noticed that if I dont give a fixed width it totally enlarges to the whole screen.
Is there any way I can change it so that the title background grows as the text grows??

Thanks in advance

#product_content_r .product_box h6.news {
width: 6em;
padding: 0.2em;
line-height: 1.6;
background-color: #C83091;
border: 0px solid black;
color: #fff;
text-decoration: none;
text-align: center;
margin-right:5px; font-size:12px;


<h6 class="news">NEWS</h6>

Reply With Quote
  #2 (permalink)  
Old December 9th, 2007, 10:44 PM
Friend of Wrox
Points: 1,315, Level: 14
Points: 1,315, Level: 14 Points: 1,315, Level: 14 Points: 1,315, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: , , .
Posts: 425
Thanks: 0
Thanked 3 Times in 3 Posts

Are you talking about a background image? Background images tile by default, so you must have done something to stop that. I don't know what, because there is no trace of any background image in the code you posted.

Reply With Quote
  #3 (permalink)  
Old December 19th, 2007, 12:36 AM
Friend of Wrox
Points: 1,749, Level: 16
Points: 1,749, Level: 16 Points: 1,749, Level: 16 Points: 1,749, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2007
Location: San Diego, CA, USA.
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts

No, I've been playing around with this and pouring over all the pages of my sites, and I've never done this either apparently.

When you use the width: 6em; style rule, it creates a magenta box 6em long. But depending on the text you have in the XHTML file, this may or may not be enough for the text. It may force the text to wrap onto a second line. If you remove the width rule, you get the heading onto one line, but the magenta box instantly snaps to the width of the screen (adjusting only for the margins). I've played with the margins and using percents and other units for the width, but the same basic problem remains. It sounds like you want the box to automatically expand to fit the length of the content. So far I haven't been able to find a solution.

...Depending on how many people you want to piss off, you could create a one cell table. I believe that would display the behavior you're looking for. ;) (Just a bad joke, and besides I'm not sure. It's been years since I did a table based layout.)


Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe

When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper

Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.
Reply With Quote

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Change background color using CSS pigtail Javascript How-To 9 April 4th, 2010 11:13 AM
Calendar Control Title Doesn't Position with CSS.. kevorkian ASP.NET 2.0 Basics 5 June 19th, 2008 11:33 AM
background image width through CSS problem inOpera iamrakesh22 CSS Cascading Style Sheets 0 May 31st, 2007 06:09 AM
CSS Background images not loading in ASP.NET 2.0 vinyel23 ASP.NET 2.0 Basics 0 January 5th, 2007 12:54 PM
Problem with background images in CSS & Tomcat MW_ Apache Tomcat 2 April 18th, 2005 08:07 AM

All times are GMT -4. The time now is 11:13 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.