1. Dentro de um arquivo CSS, regras diferentes para o tamanho de uma imagem
se o dispositivo estiver orientado verticalmente (_portrait_) ou
horizontalmente (_landscape_)
```css
img.produto { width: 200px; }
@media screen and (orientation: landscape) {
img.produto { width: 100%; }
}
all
print
screen
speech
<link rel="stylesheet" media="all" href="estilos-gerais.css" />
<link rel="stylesheet" media="screen" href="p-monitores.css" />
<link rel="stylesheet" media="print" href="p-impressao.css" />
#artigo-principal {
background-color: #ccc;
}
@media print {
#artigo-principal {
background-color: transparent;
}
}
width
, height
, max-width
, max-height
, min-width
, min-height
aspect-ratio
orientation
landscape
x portrait
) do dispositivoresolution
<!-- Arquivo de estilo para dispositivos pequenos -->
<link rel="..." media="all and (max-width: 640px)" href="small.css" />
<!-- Arquivo de estilo para dispositivos grandes -->
<link rel="..." media="all and (min-width: 641px)" href="large.css" />
div#logo {
background-image: url('img/logo.png');
}
/* 2dppx = 2 dots per pixel unit */
@media screen and (min-resolution: 2dppx) {
div#logo {
background-image: url('img/logo2x.png');
}
}
div.produto { display: inline-block; }
@media (min-width:801) and (max-width: 1024px) {
/* tela grande: 4 produtos por linha */
div.produto { width: 25%; }
}
@media (min-width:481px) and (max-width: 800px) {
/* tela média: 3 produtos por linha */
div.produto { width: 33.333%; }
}
@media (max-width: 480px) {
/* tela pequena: 2 produtos por linha */
div.produto { width: 50%; }
}
<link rel="stylesheet" href="bootstrap.css">
<link rel="stylesheet" href="meus-estilos.css">
.row
, .column
etc.s)div.fundo { background-color: #3399ff; }
body { color: #3399ff; }
.animal { width: 200px; }
.animal img { width: 1800px; }
.animal figcaption { width: 100%; }
$font-stack: Helvetica, sans-serif;
$primary-color: #333;
body {
font: 100% $font-stack;
color: $primary-color;
}
body {
font: 100% Helvetica, sans-serif;
color: #333;
}
@font-stack: Helvetica, sans-serif;
@primary-color: #333;
body {
font: 100% @font-stack;
color: @primary-color;
}
body {
font: 100% Helvetica, sans-serif;
color: #333;
}
font-stack Helvetica, sans-serif
primary-color #333
body
font 100% font-stack
color primary-color
body {
font: 100% Helvetica, sans-serif;
color: #333;
}
ul {
list-style: none;
li { display: inline-block; }
}
ul { list-style: 0; }
ul li { display: inline-block; }
@mixin border-radius($radius) {
-webkit-border-radius: $radius;
-moz-border-radius: $radius;
-ms-border-radius: $radius;
border-radius: $radius;
}
.box { @include border-radius(10px); }
.box { -webkit-border-radius: 10px; /*... */ }
.generate-columns(@n, @i: 1) when (@i =< @n) {
.column-@{i} {
width: (@i * 100% / @n);
}
.generate-columns(@n, (@i + 1));
}
.generate-columns(4);
.column-1 { width: 25%; } .column-2 { width: 50%; }
.column-3 { width: 75%; } .column-4 { width: 100%; }
.message
padding 10px; border 1px solid gray
.warning
@extend .message
color rebeccapurple
.message,
.warning { padding: 10px; border: 1px solid #eee; }
.warning { color: rebeccapurple; }