Answer the question
In order to leave comments, you need to log in
How to change the design of a site with remembering cookies?
I have the following code
Written in css:
Written in html on each page before the opening < body > tag (that's where you need it before the body tag):.eco {display: none;}
<div class="eco"><style>.head2 {display: none;} [и так далее]</style></div>
Answer the question
In order to leave comments, you need to log in
Won't work.
1. The tag div
cannot be placed before the body.
2. Styles will always be active, regardless of the display value of the wrapper.
3. Just html and css is not enough to solve the problem, you need to fasten js or some kind of server-side language.
I found such a solution
<link id="dyncss" rel="stylesheet" type="text/css" href="">
<script type="text/javascript">
function setDynCSS(url) {
if (!arguments.length) {
url = (url = document.cookie.match(/\bdyncss=([^;]*)/)) && url[1];
if (!url) return '';
}
document.getElementById('dyncss').href = url;
var d = new Date();
d.setFullYear(d.getFullYear() + 1);
document.cookie = ['dyncss=', url, ';expires=', d.toGMTString(), ';path=/;'].join('');
return url;
}
setDynCSS();
</script>
<img style="cursor:pointer; width: 30px; height:30px;" src="/social/firefox.png" onclick="setDynCSS('/_st/my.css')">
<img style="cursor:pointer; width: 30px; height:30px;" src="/social/ie.png" onclick="setDynCSS('/css/new_1.css')">
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question