Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using Some of attributes from CSS

 
Azrael Noor
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written a CSS: having 10 attributes for a tag or class

Now i am writing HTML

i will use that div class for specific affect and whole 10 attributes will apply to that objects.

Now if i want to use 8 of that div attributes,

is their any technique that i use same class and could minus two or some of it's attributes?
or have i to write the code again or write internal styles?


Kindly explain
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can override with another class, or use local styles. I tend to avoid the latter as I like to keep the style information completely separate from the structural information.
 
Azrael Noor
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have already made CSS in seperate file, and i have made two classes in it.
i want to some of attributes and ya i am not able to get what are you saying,
Could you please explain it with help of example?
.
.
and ya i haven't find anything on google.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's also possible that your CSS classes are too encompassing. Should they be broken up into smaller units?
 
Azrael Noor
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sir, i am not getting, i want to explain that again what i am trying to say

See what i am doing



and i am incorprating this code into



Now where i will call Style6
all style will be embedded

if i want to use same class style6,
but i just want to use 3 of it's attributes(Width, margin-left, margin-right), instead of five
and
i do not want to write style7, style8 for every <Table> tag.

is their any possibility to incorprate some of attributes of that class,
instead of whole and
rejecting which i donot want to use(padding and border?

if yes than how?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. It's all or nothing. But as I already said, you can override the properties that you want to be something else, or you can break up the classes into a finer grain.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric posted an example of what I meant by "finer grain". If you make your classes too big and monolithic, they become much less versatile.
 
Azrael Noor
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks bear and Eric

So by this you mean

If i want to do this
_______________

.class1
{
background-color: #CFC;
height:50%
}

.class2
{
color: #CFC; //Again
height:100% //Same but different Value
}

________________

i have to make classes again and again,
means it is recommended that for every different attributes
i should make different class

and one more thing for "BEAR"
you said
you can override the properties that you want to be something else


i am not able to understand the statement, could you give an example, please!!!


 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



What color will the text be?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic