Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove class using CSS

Tags:

css

I need to remove classes from different elements within the @media print on my CSS and add those classes on the @media screen.

Is there anyway to remove classes from the CSS file?

Something like:

@media print{     .element{/*Remove class*/} } @media screen{     .element{/*Add class*/} } 

I need to remove ui-tabs-hide added by a jQuery function (which hides the element in a weird way, as its not display:block or display:none) class from those elements at the time of printing and putting it back when finished printing.

like image 552
Amra Avatar asked Nov 18 '10 13:11

Amra


People also ask

How do I remove a class style?

In plain JavaScript, you can use the Element. classList. remove() method to remove the specific class from an element. Like jQuery's removeClass() method, this won't remove any inline styles applied to the element using the style attribute.

How do I remove a class from a div?

Use the classList. remove() method to remove a class from a div element, e.g. box. classList. remove('my-class') .

How do I delete a class in CSS media query?

You can't remove a class in a media query… only change the properties styled within it as you state. Offhand, a shadow effect shouldn't break a menu…so either you override the styles or resort to javascript to remove the class.


2 Answers

No. CSS can't modify the DOM, only its presentation.

like image 69
Quentin Avatar answered Sep 26 '22 00:09

Quentin


CSS can't take out elements from the HTML document, however you could try something like:

@media print{ element.relevantclass    {      display: none;    } 

This would tell the printed media to not display this element.

like image 22
Kyle Avatar answered Sep 25 '22 00:09

Kyle