Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css stye just for selected element

Is it possible to add style for a selected element, for example:

I have bootstrap.css

and I have

<!DOCTYPE>
<html>
<head><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"></head>
<body>
<div id='a' class ='container'></div>
<div id='b' class ='container'></div>
</body>
</html>

Is it possible add bootstrap.css style only for #a element with jQuery or something else?

like image 513
Mamen Avatar asked Feb 13 '26 17:02

Mamen


2 Answers

You can do it using SASS Inheritance.

Please refer below code :

'#a {
     @import url(bootstrap.css);
}'

This will render you bootstrap css with "#a" prefix parent.

Thanks

like image 80
Vasimkhan Avatar answered Feb 15 '26 08:02

Vasimkhan


Actually you can not do so. After all its a whole html document. Whichever css you include, It will apply to all elements of page.

One solution is for #b, You need to override the styles, If any that are applied by bootstrap.css

like image 35
Prasad Avatar answered Feb 15 '26 06:02

Prasad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!