To hide the scroll bar if not needed with CSS, we set the overflow-y
property.
For instance, we write
div {
overflow-y: auto;
}
to only show the vertical scrollbar only when needed with overflow-y: auto;
.
To hide the scroll bar if not needed with CSS, we set the overflow-y
property.
For instance, we write
div {
overflow-y: auto;
}
to only show the vertical scrollbar only when needed with overflow-y: auto;
.
To turn off word wrapping in CSS, we set thr white-space
property.
For instance, we write
div {
white-space: pre-wrap;
}
to add the white-space: pre-wrap;
style to turn off word wrapping in the div.
To vertically align text inside a flexbox with CSS, we set the align-items
property.
For instance, we write
ul {
height: 100%;
}
li {
display: flex;
justify-content: center;
align-items: center;
background: silver;
width: 100%;
height: 20%;
}
to add align-items: center;
to vertically center align the content in the li element.
We make li elements flex containers with display: flex;
.
To select elements with two classes with CSS, we add both class selectors.
For instance, we werite
.foo.bar {
color: red;
}
to add select elements with both the foo
and bar
class applied and set their content color to red.
To fix CSS text-overflow: ellipsis; not working, we should apply the text-overflow
style to an inline-block element.
For instance, we write
.app a {
height: 18px;
width: 140px;
padding: 0;
overflow: hidden;
position: relative;
display: inline-block;
margin: 0 5px 0 5px;
text-align: center;
text-decoration: none;
text-overflow: ellipsis;
white-space: nowrap;
color: #000;
}
to make the a
elements inline block with display: inline-block;
.
Then we can apply the text-overflow: ellipsis;
style.