View on GitHub

reading-notes

Reading Notes about Markdown-Html-Css-JavaScript

Responsive Web Design

web

What Is Responsive Web Design?

Responsive design is an approach to web design that makes your web content adapt to the different screen and window sizes of a variety of devices.

Why Responsive Design Matters?

When over half of your potential visitors are using a mobile device to browse the internet, you can’t just serve them a page designed for desktop. It would be hard to read and use, and lead to bad user experience.

The Building Blocks of Responsive Web Design

1- CSS and HTML

Example :

img {
width: 100%;
}

Or we could target the specific class “full-width-img” by adding a period in front.

.full-width-img {
width: 100%;
}

2- Media Queries

A fluid layout relies instead on dynamic values like a percentage of the viewport width.


4- Flexbox Layout


### Common Responsive Breakpoints

Common screen sizes



Float and Clear

How floats behave?

HTML is bound by some rules, in particular, the normal flow. In the normal flow, each block element (div, p, h1, etc.) stacks on top of each other vertically, from the top of the viewport down. But by using float the blocks will be sitting side by side.

Example :

 img {
	float: right;
}

The clear property can have one of the following values:

The CSS may look complicated at first, but the raw essentials are:

Set the grid container #grid-col to display: grid. Then use grid-template-columns: auto auto auto to control the number of columns the grid has; In this case, we have 3 columns in this grid. Take note – auto will leave it to the browser to determine the width of the columns. We can also specify exact px or %. Finally, we add media query @media screen and (max-width: XYZpx) to add support for mobile devices – Simply change grid-template-columns so that there are fewer grid items per row on a small screen.

2) GRID ROWS

Just like the columns, use grid-template-rows to control the height. By default, the rows are already set to auto. So don’t bother to define grid-template-rows unless you want a specific height for a certain row.

Property| Description ———|——– display: grid |The container will display as a grid. grid-template-columns: auto px % |Set the width of the grid columns. grid-template-rows: auto px % |Set the width of the grid rows. grid-column-gap: px % |Spacing in-between the cells horizontally. grid-row-gap: px % |Spacing in-between the cells vertically. grid-gap: px %| Sets spacing in-between the cells horizontally and vertically. grid-column-start: |N and grid-column-end: N How many columns to span across. grid-row-start: |N and grid-row-end: N How many rows to span across. grid-template-areas: |’AREA AREA AREA’ Create a grid template with area names. grid-area: |AREA Assign this cell to this area in the template. __ Note :

“SMACSS : is more style guide than rigid framework. There is no library within here for you to download or install. There is no git repository for you to clone. SMACSS is a way to examine your design process and as a way to fit those rigid frameworks into a flexible thought process. It is an attempt to document a consistent approach to site development when using CSS