Latest web development tutorials
×

CSS Reference Manual

CSS Reference Manual CSS Selector CSS Voice Reference CSS Web Secure Font CSS Animation CSS unit CSS Colour CSS Legal color values CSS The color name CSS Color Hexadecimal value CSS Browser support

CSS Attributes

align-content align-items align-self all animation animation-delay animation-direction animation-duration animation-fill-mode animation-iteration-count animation-name animation-play-state animation-timing-function appearance backface-visibility background background-attachment background-blend-mode background-clip background-color background-image background-origin background-position background-repeat background-size border border-bottom border-bottom-color border-bottom-left-radius border-bottom-right-radius border-bottom-style border-bottom-width border-collapse border-color border-image border-image-outset border-image-repeat border-image-slice border-image-source border-image-width border-left border-left-color border-left-style border-left-width border-radius border-right border-right-color border-right-style border-right-width border-spacing border-style border-top border-top-color border-top-left-radius border-top-right-radius border-top-style border-top-width border-width bottom box-align box-direction box-flex box-flex-group box-lines box-ordinal-group box-orient box-pack box-shadow box-sizing caption-side clear clip color column-count column-fill column-gap column-rule column-rule-color column-rule-style column-rule-width column-span column-width columns content counter-increment counter-reset cursor direction display empty-cells filter flex flex-basis flex-direction flex-flow flex-grow flex-shrink flex-wrap float font @font-face font-family font-size font-size-adjust font-stretch font-style font-variant font-weight grid-columns grid-rows hanging-punctuation height icon justify-content @keyframes left letter-spacing line-height list-style list-style-image list-style-position list-style-type margin margin-bottom margin-left margin-right margin-top max-height max-width @media min-height min-width nav-down nav-index nav-left nav-right nav-up opacity order outline outline-color outline-offset outline-style outline-width overflow overflow-x overflow-y padding padding-bottom padding-left padding-right padding-top page-break-after page-break-before page-break-inside perspective perspective-origin position punctuation-trim quotes resize right rotation tab-size table-layout target target-name target-new target-position text-align text-align-last text-decoration text-decoration-color text-decoration-line text-decoration-style text-indent text-justify text-outline text-overflow text-shadow text-transform text-wrap top transform transform-origin transform-style transition transition-delay transition-duration transition-property transition-timing-function unicode-bidi vertical-align visibility white-space width word-break word-spacing word-wrap z-index

CSS3 @media query

Examples

If the document width less than 300 pixels is to modify the background presentation (background-color):

@media screen and (max-width: 300px) {
body {
background-color: lightblue;
}
}

try it"

Definitions and use

Use @media queries, you can define different styles for different media types.

@media can be set for different screen sizes different styles, especially if you need to set design responsive pages, @ media is very useful.

When you reset the browser size of the process, the page will be re-render the page based on the browser's width and height.


Browser Support

Figures in the table indicate support @media rules first browser version number.

Rule
@media twenty one 9 3.5 4.0 9


CSS Syntax

@media mediatype and | not | only (media feature) {
CSS-Code;
}

You can also use different stylesheets for different media:

<link rel = "stylesheet" media = "mediatype and | not | only (media feature)" href = "mystylesheet.css">

media type

value description
all For all devices
aural Obsolete. For speech and voice synthesizer
braille Obsolete. Braille equipment used in touch-feedback
embossed Obsolete. Blind printing apparatus for printing
handheld Obsolete. For handheld devices or smaller devices, such as PDA and small telephone
print For printers and print preview
projection Obsolete. For projection equipment
screen For computer screens, tablet PCs, smart phones and the like.
speech Applied to screen readers and other sound equipment
tty Obsolete. For fixing the character grid, such as the telegraph, terminal equipment and limited character of the portable device
tv Obsolete. For TV and Web TV

Media features

value description
aspect-ratio Define the output device in the visible region of the page width to height ratio
color Define the output device in each group the number of the color original. If it is not a color device, the value is equal to 0
color-index The number of entries in the color look-up table is defined in the output device. If you do not use a color lookup table, the value is equal to 0
device-aspect-ratio Screen definition output device visible width to height ratio.
device-height Screen definition output device visible height.
device-width Screen definition output device visible width.
grid Output device used to query whether the grid or lattice.
height Define the output device in the visible region of the page height.
max-aspect-ratio Screen definition output device visible maximum ratio of width to height.
max-color Define the maximum number of output devices each set of color original.
max-color-index The maximum number of entries in the color look-up table is defined in the output device.
max-device-aspect-ratio Screen definition output device visible maximum ratio of width to height.
max-device-height Screen define the output devices visible to the maximum height.
max-device-width Screen definition output device maximum visible width.
max-height Define the output device in the visible region of the maximum height of the page.
max-monochrome Is defined in a monochrome frame buffer contains per pixel is the maximum number of monochrome original.
max-resolution Maximum resolution defines the device.
max-width Define the output device in the visible region of the maximum width of the page.
min-aspect-ratio Define the output device in the area of ​​the page visible minimum ratio of width to height.
min-color Define the output device each set minimum number of the color original.
min-color-index The minimum number of entries in the color look-up table is defined in the output device.
min-device-aspect-ratio Screen define the output devices visible minimum ratio of width to height.
min-device-width Screen output devices defined minimum visible width.
min-device-height Minimum define the output device's screen visible height.
min-height Define the output device in the visible region of the minimum height of the page.
min-monochrome The minimum number of color originals is defined in a monochrome frame buffer contains per pixel
min-resolution The minimum resolution defines the device.
min-width Define the output device in the visible region of the minimum width of the page.
monochrome Is defined in a monochrome frame buffer contains per pixel monochrome original number. If it is not a monochrome device, the value is equal to 0
orientation Define the output device in the visible region of the page height is greater than or equal to the width.
resolution Define the resolution of the device. Such as: 96dpi, 300dpi, 118dpcm
scan Scanning Process Definition TV type of equipment.
width Define the output device in the visible region of the page width.


Examples

More examples

Examples

Use @media queries to create responsive design:

@media only screen and (max-width : 500px) {
.gridmenu {
width: 100%;
}

.gridmain {
width: 100%;
}

.gridright {
width: 100%;
}
}

try it"

Related Pages

CSS tutorial: CSS media types