Jump to content
  • 0

разный scc в зависимости от разрешения монитора пользователя


ryar
 Share

Question

4 answers to this question

Recommended Posts

  • 0

Это возможно средствами самой css в некоторых браузерах. Вот, например одна из стандартных css, используемых для страницы «сервер не найден» в опере:

@charset "utf-8";
/* Stylesheet for the Opera error documents */
/* Copyright 2008 Opera Software */
@media tv {html {font-size: 150%;}}
@media screen, projection, tv, speech {
html {
font-family: sans-serif;
color: hsl(0,0%,22%);
background-color: hsl(0,0%,93%);
margin: 0 auto 10px;
border-width: 0 1px;
border-color: hsl(0,0%,57%);
border-style: solid;
voice-family: female;
}
html, head {max-width: 660px;}
head {
margin: auto;
position: relative;
display: block;
speak: normal;
}
title {
font-size: 130%;
font-weight: bold;
text-transform: uppercase;
color: hsl(0,100%,40%);
position: absolute;
top: 20px;
left: 10px;
display: block;
speak: normal;
}
html[dir="rtl"] title {
left: auto;
right: 10px;
}
html[lang^="el"] title {text-transform: none;}
title::after {
content: "!";
speak: none;
}
body {
color: inherit;
background-color: hsl(0,0%,96%);
margin: 0;
}
h1 {
font-family: sans-serif;
font-size: 130%;
text-align: right;
letter-spacing: -1px;
color: hsl(0,0%,29%);
background-image: url(images/top.png);
background-repeat: repeat-x;
padding: 20px 10px 15px 5em;
margin: 0;
border-bottom: 1px solid hsl(0,0%,57%);
}
html[dir="rtl"] h1 {
text-align: left;
letter-spacing: normal;
padding: 20px 5em 15px 10px;
}
h2 {
font-family: sans-serif;
font-size: 75%;
font-weight: normal;
letter-spacing: -1px;
color: hsl(0,0%,29%);
background-color: hsl(0,0%,89%);
background-image: url(images/bar.png);
background-repeat: repeat-x;
background-position: 0px -5px;
padding: 5px 7px;
margin: 0;
border-top: 1px solid hsl(0,0%,57%);
border-bottom: 1px solid hsl(0,0%,57%);
}
html[dir="rtl"] h2 {letter-spacing: normal;}
a {
color: hsl(0,0%,29%);
background-color: transparent;
}
p {
font-size: 83%;
-o-text-overflow: ellipsis;
margin: 20px 10px;
overflow: hidden;
}
li {
font-size: 83%;
margin: 10px 10px 0 0;
}
body::after {
content: "";
background-color: hsl(0,0%,98%);
background-image: url(images/center.png);
background-repeat: repeat-x;
background-position: left bottom;
border-top: 1px solid hsl(0,0%,57%);
height: 20px;
width: 100%;
display: block;
speak: none;
}
dl {
font-size: 83%;
margin: 10px;
}
dt {
font-weight: bold;
margin: 0 5px 0 0;
display: run-in;
}
dd {margin: 0;}
cite {
font-weight: bold;
white-space: pre;
}
pre {
font-size: 75%;
white-space: pre-wrap;
line-height: 160%;
background-color: hsl(0,0%,98%);
padding: 5px;
margin: 20px;
border: 1px solid hsl(0,0%,27%);
overflow: auto;
}
pre em {
font-weight: bold;
font-style: normal;
color: white;
background-color: black;
padding: 2px;
speak: spell-out;
}
pre em.error {
color: white;
background-color: hsl(0,100%,40%);
}
}
@media screen and (max-width: 800px), projection and (max-width: 800px), tv {
title, h1 {font-size: 110%;}
h1 {padding: 20px 10px 7px 6em;}
}
@media screen and (max-width: 350px), projection and (max-width: 350px), tv and (max-width: 350px) {
h1 {
text-align: center;
background-position: 0 -2px;
}
head {
font-weight: bold;
text-align: center;
background-color: hsl(0,100%,33%);
padding-top: 0.1em;
width: 100%;
height: 1.2em;
display: block;
}
title {
color: hsl(0,0%,96%);
position: static;
}
ul {
padding-left: 30px;
}
pre {
margin: 10px 5px;
}
}
@media screen and (max-width: 300px), projection and (max-width: 300px), tv and (max-width: 300px) {
h1 {
font-size: 100%;
padding: 15px 5px 7px;
}
}
@media screen and (max-width: 250px), projection and (max-width: 250px), tv and (max-width: 250px) {
h1 {font-size: 83%;}
}
@media all and (min-width: 1025px) {html, head {max-width: 700px;}}
@media all and (min-width: 1281px) {html, head {max-width: 800px;}}
@media all and (min-width: 1601px) {html, head {max-width: 900px;}}
@media tv {title, h1 {font-size: 90%;}}
@media print {
* {border: none;}
h2, h2+ul, head {display: none;}
h1 {
font-size: 13pt;
font-weight: bold;
page-break-before: avoid;
page-break-after: avoid;
}
}

Link to comment
Share on other sites

  • 0

Спасибо, идея интересная, но в данный момент мне не подходит, нужен простой яваскрипт который бы определял разрешение монитора и загружал соответственный css. Есть идея немного менять дизайн для различных разрешений монитора. Еще раз спасибо. ;)

Link to comment
Share on other sites

  • 0

вот нашел такое решение, меня полностью устроило

<script language=JavaScript>
alert("Размер экрана составляет:"+screen.width+"х"+screen.height+"px");
if (screen.width == '640') {document.write ('<LINK href="1.css" rel="stylesheet" type="text/css">'); alert("640")}
else {if (screen.width == '800') {document.write ('<LINK href="2.css" rel="stylesheet" type="text/css">'); alert("800")}
else {if (screen.width == '1024') {document.write ('<LINK href="3.css" rel="stylesheet" type="text/css">'); alert("1024")}
else {if (screen.width == '1280') {document.write ('<LINK href="3.css" rel="stylesheet" type="text/css">'); alert("1280")}
else {document.write ('<LINK href="N.css" rel="stylesheet" type="text/css">'); alert("xxx")}
}
}
}
</script>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy