How to change the CSS of entire page/website on click?
Tags: javascript,html,css,stylesheet
Problem :
Is it possible to have 3-4 CSS on a page, and then on any event, say click, change the css for entire webpage. This way we can give our user the ability to change the theme. I know we can change the css of an element by:
$("#myElementID").removeClass("class1").addClass("class2");
Solution :
Yes, it is possible. Typically what you would do is write a JavaScript function that will change, or add, or remove a style sheet from the <head>
of the document. To make the experience a little better you'll typically store the user's preference in a cookie. There's an article on A List Apart that show how to implement this.
And of course, you can do this with jQuery... you may want to check out the source of jStyler.
CSS Howto..
Firebug's CSS panel currently doesn't offer an option to copy the URL of the webfont yet. So I created an issue, which was copied over to GitHub as issue #7320...
You can certainly use CSS3 gradient and clip properties .. I am aware of webkits which I used for, but not sure about other browsers, if you want you can...
use px instead of percentage for example h2{font-size:14px; height:50px;}
That looks like fancy box. Fancy box is (IMHO) the best lightbox out there. Very reliable and very versatile. Go here for info and examples: http://fancybox.net/ Go here for usage:...
Oh, well, do I feel a bit stupid! The extra padding was blank space part of the image itself. It works fine with a corrected image: http://jsfiddle.net/bendog/gvtqwhw0/24/ Here's the updated...
Using tables would be the best way of doing this <table cellspacing="0" cellpadding="0" style="width: 100%; padding: 0pt; margin: 0pt;"> <tbody> <tr align="top"> <td style="width: 100%; height: 85px;"> <div class="left_bg"> </div>...
**EDIT: Since the question has been clarified, the answer is you have to use RGBA. Just hit up a site like http://www.rgbtohex.net/hextorgb/ to do the conversion from HEX to RGB....
You could use the CSS3 "columns" property as shown on CSS-Tricks
If you absolutely can't make your index a php file. Then, you can always make an ajax request to get the header and footer. However, it is very simple to...
You are using CSS3, which is not supported by all browsers. To do this in a cross-browser compatible way you need to use alternating class, jQuery, or some other method...
Firstly, display:none is not universally considered to be a SEO faux pas; crawlers can still 'crawl' that text; there are just conflicting theories as to if it affects reputation, or...
There are many ways you to have fixed and fluid layout: Bootstrap-http://twitter.github.com/bootstrap/ Use of Media Queries-which I prefer most @media screen and (max-device-width : 320px) { body or yourdiv element...
I set a width on both elements as well as the wrapper <h1>, to make sure they would float next to each other and there would be no text underneath...
Two possible ideas: 1. Use a cookie to save state and check that when you call each page (http://www.w3schools.com/js/js_cookies.asp) 2. Use local storage to save state. Generally speaking it acts...
You can style it like any other document if you include the reference to the CSS file: <?xml-stylesheet href="my-style.css"?> ... rest of document here... Taken from the w3 documentation. EDIT...
You can not neutralize CSS rules whithout overriding. So you have to do as you suggested in the answers above.
html <div id="ban01" class="banner ban01"> </div> <div id="ban02" class="banner ban02"> </div> <div id="ban03" class="banner ban03"> </div> <div id="ban04" class="banner ban04"> </div> style .banner { height: 50px } .ban01 { background:...
So, you want to know what's happening, huh? absolute positioning aligns the element "on top of" the parent who has a relative position. So, placing your square like: +-----+-----------------------+ |XXXXX|...
Browsers, for the most part, follow various specifications. Colours and gradients are defined in various CSS specifications which are maintained by the World Wide Web Consortium (W3C). The CSS2 specification,...
Try to give a class to <span> like: <span class="className"> text text </span> then write on CSS for it : .className { color: red; } OR You can give class...
Just move your button inside your navbar-header div, like this: <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> <span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar">...
To centralize horizontally -Without using flexbox See this fiddle HTML <button type="button">Welcome</button> To make the button centralized, use the following CSS button{ display: block; margin:0 auto; } To centralize horizontally...
there is probably a better way to do it but to illustrate your problem, you are overwriting the click eventlistener on line 4. To get a similar effect, you would...
The text is centered, just the table doesn't fill the width of its enclosing area: table.t_group_matches {width:100%} ...
You could add a second class to one of the controls. <div class = "first_class second_class"> <div class = "first_class"> Then do something like: first_class { attributes } second_class {...
If you mean a hover effect on the table-cell, then this should work: tr.TableData td:hover { background-color: red; } ...
The overflow: hidden contains the floated lis inside the ul by creating a blocking context, there is a in-depth explanation here: Adding CSS border changes positioning in HTML5 webpage The...
Try applying negative marging or negative top to your chart container... Ex: #main { position:relative; width:95%; left:3%; border: 3px solid green; padding-top: 0px; top:-20px } or #main { position:relative; width:95%;...
better to just use .addClass even if you have 1 or more. More maintainable and readable. If you really have the urge to do multiple css props then use NB...
Have you tried using the list_columnSizing: false option? For more info visit: http://getfuelux.com/extensions.html#bundled-extensions-list...