Jump to content

css nesting


hackalive

Recommended Posts

Hi guys,

 

I saw this in some CSS ages ago and cannot remember where so cannot remember how it goes exactly ... but i'd like to do somehting like this with my css:

 

<htmi id="something">

 

<style>

#something {

 

 h1 {

}

 

}

 

#other {

 

 h1 {

}

 

}

 

so if anyone know how it works or how to make it work thatd be great!

 

cheers

Edited by hackalive
Link to comment
Share on other sites

CSS doesn't have "nesting" like that but you can

 

 

CSS doesn't have it, but SASS does. SASS is pretty much CSS on steroids. It saves a lot of time and aggravation. Not only does it let you nest elements, but it also lets you assign variables to values. So instead of having to scroll through your style sheet for that hex-code or rearrange and reorganize your structure, you can do something like $white=#fff; and use it over and over again.

 

Give it a try. 

Link to comment
Share on other sites

Its actually NOT tedious at all. I use Less for everything, running a program call WinLess in the background. Every time I change a Less file, the Less gets compiled into a bootstrap.css file in the css folder automatically. Bootstrap.css is also minified!

 

Couldnt be easier. Use it.

Edited by DaveyK
Link to comment
Share on other sites

  • 2 weeks later...

I can very much understand people when they say that they want to use .sass because of variables...

 

Continuously assigning margin: 0 auto; or whatever styles you might repeat over a few lines for multiple selectors can get tiresome!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.