Media Queries is a CSS3 module that helps you design responsive websites by defining different style rules for different devices or media types. Based on these rules, content is rendered to adapt to various conditions, such as, screen sizes, browser window sizes, device sizes and orientation, and resolution.
You can add media queries using the @media rule to your CSS. Or, you can create separate style sheets for different media types and then call them using the following syntax:
<link rel='stylesheet' media='all' href='normal.css' /> <link rel='stylesheet' media='print' href='print.css' /> <link rel='stylesheet' media='screen and (min-width: 701px)' href='medium.css' />
The browser on a device checks the media query and uses the corresponding CSS file to display the web page.
For more information, see this article.
You can add the media queries by adding the relevant code to your HTML or CSS files. In addition, Dreamweaver lets you create and manage media queries easily using:
Visual Media Query bars are a visual representation of the media queries present in a page. These bars help you visualize your web page at different breakpoints and how different components of your web page reflow in different viewports. While you view your page in different viewports, you can make design changes that are specific to a viewport without affecting the page design in other viewports.
Visual Media Query consists of three bars as horizontal rows, each representing a category of media query:
- Green: Media queries with max-width conditions
- Blue : Media queries with both min-width and max-width conditions
- Purple : Media queries with min-width conditions
Opomba:
The media queries listed in the CSS designer panel are also prefixed with these colors.
Each category can consist of one or more media queries. If a media query condition is not defined in the document, then the corresponding visual media qurey bar, too, will not be displayed. For example, if the document does not contain min-width conditions, then the purple bar is not displayed.
The breakpoint values are indicated on the bars - min-width at the left and max-width at the right of the bar.
A. Breakpoints B. Visual Media Query bars C. Add media query icon D. Scrubber
The Visual Media Query bar is visible in Live View by default. To hide the bar, use the Toggle Visual Media Queries bar in the toolbar.
To view your page in a specific size (breakpoint), click the corresponding media query bar. The document will snap to the breakpoint.
To resize the view to the size of the Dreamweaver document window, do one of the following actions:
- Double-click anywhere in the grey area at the right of the document where you see the text 'Double Click To Fit Width'. If you don't see the grey area, drag the scrubber to the left.
- Select the Full Width option in the drop-down list at the bottom of the document window.
-
The media queries are automatically updated with the new min-width and/or max-width values. A notification is displayed to indicate that the media query was successfully edited. If there are multiple media queries that correspond to the visual media query bar, all the media queries are updated. The number of media queries that were updated is displayed along with the success message.
Opomba:
To undo, press Ctrl+Z (Win) or Cmd+Z (Mac).
Alternatively, you can double-click the breakpoint values to type in the values using your keyboard.
Opomba:
To undo, press Ctrl+Z (Win) or Cmd+Z (Mac).
Opomba:
To undo, press Ctrl+Z (Win) or Cmd+Z (Mac).