- This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
- The forum ‘CSS’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Hi, I’m just a beginner coder – sorry. I have taken some code and kind of repeated it to get the effect I want. However, its lines and lines of CSS. I know there is a way of shortening it down, but I can’t get it to work.
Its here at Code pen…
http://codepen.io/rescott72/pen/xVmYzQ
Any help would be greatly appreciated
Thanks
RS
Lines and lines of code? Welcome to coding. ;)
The main thing you can do to shorten it, is to not assign styles to every single element individually. Instead, give all those elements a certain classname, and then assign all the common stuff (in other words, the properties they all share) to that classname.
Everything that certain elements share, should be put in a class, and put those properties in a class.
Here’s a start: http://codepen.io/senff/pen/eZbMVo
It’s far from optimized, and there’s something to say about a number of other things (using IDs instead of classes for example), but this example is just to give you an idea how you can make elements share properties, instead of assigning the same properties to each individual element.
Good luck!
Thanks man, I’m beginning to understand it :)