There are 3 primary ways.
The third method is the most desired approach.
CSS selectors vary in size length and complexity, but they are primarily based off of 3 core selector methods.
Changes the background appearance of the element.
repeat-x
repeats the image across the x axisrepeat-y
repeats the image across the y axisno-repeat
makes the image only appear once
.item{
background-color: #ff0000;
background-color: blue;
background-image: url(http://via.placeholder.com/350x150);
background-image: url(../images/me.jpg);
background-repeat: repeat-x;
background-repeat: no-repeat;
background-position: center center;
background-position: 10px 10px;
}
This CSS property defines the borders around an element.
solid
the most commondashed
dotted
.fig1{
border-color: red;
border-style: solid;
border-width:5px;
}
.fig2{
border-color: navy;
border-style: dotted;
border-width:10px;
}
.fig3 {
border: 5px solid red;
}
.fig4 {
border:10px dotted navy;
}
.fig6 {
border-left: 5px solid red;
}
.fig7 {
border: 10px dotted navy;
border-right-style:solid;
border-right-width:5px;
}
.fig8 {
border: 5px solid red;
border-bottom:none;
}
.fig9 {
border-bottom:none;
border: 10px dotted navy;
}
CSS Margins add spacing around an element.
CSS Padding add spacing inside an element.
5px
applies 5 pixels to all 4 sides.5px 10px
applies 5px to top and bottom and applies 10px to left and right.5px 10px 15px 20px
.fig10 {
/* Applies 5px to all 4 sides */
margin: 5px;
}
.fig11 {
/* Applies 5px to all 4 sides */
margin: 5px 5px 5px 5px;
}
.fig12{
/*Applies 10px to top and bottom
and 30px left and right*/
margin:10px 30px;
}
.fig13 {
margin: 5px;
padding:15px;
}
.fig14 {
margin:10px 30px;
padding:30px 10px;
}
See the Pen UA-ITR-Margin Auto by Jon (@Middaugh) on CodePen.
Sets the specific height and width of a block element
.fig15{
height:100px;
width:250px;
}
/*Applying this to a span tag*/
.fig16{
height:100px;
width:100px;
}
.fig17{
max-width:100px;
}
The CSS display property is used to change the default rendering style of an element.
You can change any element to display any type.
how now
brown cow
Will the text all be on one line?
how now
brown cow
Will the text all be on one line?
how now
brown cow
Will the text all be on one line?
Yes, but the spacing has to be tweaked. Inline block acts like an inline element but can have a set width.
See the Pen UA-ITR-CSS-Dispaly by Jon (@Middaugh) on CodePen.
Float changes the position of an element and provides advanced layout to websites.
See the Pen UA-ITR-CSS-Floats Example by Jon (@Middaugh) on CodePen.
Clear resets floats and allows content to continue down the page.
See the Pen UA-ITR-CSS-Floats by Jon (@Middaugh) on CodePen.
Why is the footer floating when it doesn't have float styling?
Flexbox provides a more predictive page layout for responsive screens. It doesn't use floats and adjusts to the available space better than traditional floats. Flexbox aims to fill all available space without overflowing its container.
It has gained a lot of popularity over the years. It doesn't support older versions of IE.
The flex container is the element that is wrapping all of the items you want to align.
To implement Flexbox, we need to apply a property to a container.
.container{
display:flex;
}
See the Pen UA-Flex-Flex by Jon (@Middaugh) on CodePen.