we know how to modify
fonts, colors, spacing, and borders
useful and necessary changes,
but not the hard part of CSS !
things become more interesting
when you start moving stuff around the page !
we will demonstrate different positioning tags
using this example
float
propertyclear
propertyposition
propertyfloat
and clear
position: static
default valueposition: relative
works like static but you can adjust the position of the element relative to where it would have naturally been
position: absolute
on an element lets you top
, bottom
, left
, and right
position: fixed
is like absolute, but relative to the window (fixed things won't move as the user scrolls)
position
property problem
as soon as you start positioning content,
it is taken out of the normal flow of content on the page
and will overlap other content
you need to think of all of the possible ways your content can overlap on different devices and window sizes !
opacity
propertyz-index
propertydisplay
propertyone of the difficult things about designing for the web
is that we don't get to really control
the way our content is viewed
the user's web browser is responsible for processing our HTML, CSS, and JavaScript
when designing web pages, you should try to create responsive designs
that is, make sure your pages are nicely readable on a wide variety of devices
many beginners to web design make the mistake of only looking at their pages on their own screen, and never test on larger or smaller screens
be careful not to fall into his trap
let's check out the positioning example with different device sizes
body {
max-width: 40em;
line-height: 1.4;
margin: 1em auto;
color: #333;
}
viewport
meta tag
<meta name="viewport" content="width=device-width,initial-scale=1" />
assigning CSS properties based on screen size, screen type, screen orientation, ...
as an example, they give us a way to express "on a smaller screen, do this ..." in CSS
* for more examples lets look at here
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" />
<link rel="stylesheet" href="bootstrap-changes.css" />
in bootstrap, the page is automatically divided up into 12 columns, you can create content that takes up any number of these columns
<section class="container">
<div class="row">
<nav class="col-xs-3"> [the menu] </nav>
<main class="col-xs-9"> [main content] </main>
</div>
</section>
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-4"> … </div>
<div class="col-xs-12 col-sm-6 col-md-4"> … </div>
<div class="col-xs-12 col-sm-6 col-md-4"> …
<figure class="hidden-xs-down">…</figure>
</div>
</div>
they make positioning much easier than fighting with float and position yourself, they are used on many modern web sites for exactly this reason
many web sites use them!
and so its default styles start to look very generic and familiar
remember that the CSS framework
is just a stylesheet like any other;
you don't have to forget everything
you know about CSS when you start using it
e.g. you can override some of tags to customize the look to your own taste