CSS Advanced #2
object-fit
property is used to specify how an <img> or <video> should be resized to fit its container.width: 200px;
height: 400px;
object-fit: cover;
}
All Values of The CSS object-fit Property
The object-fit
property can have the following values:
fill
- This is default. The replaced content is sized to fill the element's content box. If necessary, the object will be stretched or squished to fitcontain
- The replaced content is scaled to maintain its aspect ratio while fitting within the element's content boxcover
- The replaced content is sized to maintain its aspect ratio while filling the element's entire content box. The object will be clipped to fitnone
- The replaced content is not resizedscale-down
- The content is sized as if none or contain were specified (would result in a smaller concrete object size)
CSS Buttons:
Learn how to style buttons using CSS.
Example:
.button {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}
Use the border
property to add a colored border to a button:
.button1 {
background-color: white;
color: black;
border: 2px solid #4CAF50; /* Green */
}
Hoverable Buttons:
transition-duration: 0.4s;
}
.button:hover {
background-color: #4CAF50; /* Green */
color: white;
}
Disabled Buttons:
opacity: 0.6;
cursor: not-allowed;
}
Button Groups:
float:left
to each button to create a button group:CSS Flexbox Layout Module:
Before the Flexbox Layout module, there were four layout modes:
- Block, for sections in a webpage
- Inline, for text
- Table, for two-dimensional table data
- Positioned, for explicit position of an element
The Flexible Box Layout Module, makes it easier to design flexible responsive layout structure without using float or positioning.
Example :
<div class="flex-container">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
The flex-direction Property:
The flex-direction
property defines in which direction the container wants to stack the flex items.
Example :
.flex-container {
display: flex;
flex-direction: column;
}
The flex-wrap Property:
The flex-wrap
property specifies whether the flex items should wrap or not.
Example:
.flex-container {
display: flex;
flex-wrap: wrap;
}
background-color: #f1f1f1;
width: 100px;
margin: 10px;
text-align: center;
line-height: 75px;
font-size: 30px;
}
The flex-flow Property:
The flex-flow
property is a shorthand property for setting both the flex-direction
and flex-wrap
properties.
Example :
.flex-container {
display: flex;
flex-flow: row wrap;
}
Comments
Post a Comment