Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4.5.1 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4.5.1: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-84677-3
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4.5.1 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 21st, 2016, 09:21 PM
Registered User
 
Join Date: Feb 2016
Posts: 6
Thanks: 3
Thanked 0 Times in 0 Posts
Default Chapter 3: Constants in CSS

In Chapter 3, I see that in several places there are widths set to a value of 844px. It begged the question, can you define a constant at the top of the CSS file and set all those items to that constant? My research on this on the web seems to imply while there might be hacks to do this, there really is no CSS approved way of doing this which surprised me.

I guess in the example in the book on page 78, you COULD define the width in just one place by writing:

Code:
header, #PageWrapper, nav, footer
{
  width: 844px;
}
and then proceed to have second sets of blocks for each individual element with the other properties specified. I didn't like this approach so much because then you can't just look in one spot and see all things that apply to the header (for example). But maybe that's not the way I should be thinking about this.

I was just curious how people approach this question.

Thanks
 
Old February 22nd, 2016, 11:36 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yeah, it's a common complaint about CSS. You could take your approach but I don't like it for the reason you mentioned.

An alternative is to use something like Less or Sass which allow you to do exactly that.

More info:

http://sass-lang.com/
http://lesscss.org/

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Constants: Where do they go? DragonLEG BOOK: Beginning ASP.NET 4 : in C# and VB 1 June 11th, 2011 02:02 PM
Changing Constants within a session mat41 Classic ASP Basics 2 August 27th, 2009 12:11 AM
declaring constants and pointer constants proslambano BOOK: Ivor Horton's Beginning Visual C++ 2005 3 March 6th, 2007 03:32 PM
Constants in XSL austinf XSLT 2 August 29th, 2006 06:04 AM
DriveType constants fordrs3 Beginning VB 6 1 June 22nd, 2003 08:23 AM





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