/* To solve overflow issue in IE,
always use properties separately,
do not use short hand */
div {
overflow-x: hidden;
overflow-y: auto;
}
.my-div{
overflow: hidden;
}
.my-div-1{
overflow-x: hidden;/* Overflow from the div horizanlty will be hidden*/
overflow-y: hidden;/* Overflow from the div vertically will be hidden*/
}
.scroll-div{
height: 150px
overflow: scroll;
/* Add scrollbar to the div when its height exceded 150px*/
/* Can be used horizanlty or vertically according to your layout*/
}
div{
overflow: scroll;
}
visible - Default. The overflow is not clipped. The content renders outside the element's box
hidden - The overflow is clipped, and the rest of the content will be invisible
scroll - The overflow is clipped, and a scrollbar is added to see the rest of the content
auto - Similar to scroll, but it adds scrollbars only when necessary
div {
width: 200px;
height: 65px;
background-color: coral;
overflow: visible;
}
CSS allows us to control the vertical or horizontal scrollbar with two properties.
overflow-x /*controls the horizontal scrollbar*/
overflow-y /*controls the vertical scrollbar*/
overflow-x /*and overflow-y have the same values as the overflow property*/
auto
scroll
visible
hidden
#wrapper {
width: 500px;
border: 1px solid black;
overflow: hidden; /* add this to contain floated children */
}
#first {
width: 300px;
float:left; /* add this */
border: 1px solid red;
}
#second {
border: 1px solid green;
float: left; /* add this */
}
/*
Overflow Property in CSS Controls the overflow of one element over another
*/
// If we didn't want it to overflow we can just do this
selector {
overflow: hidden;
}
#wrapper {
width: 500px;
border: 1px solid black;
overflow: hidden; /* will contain if #first is longer than #second */
}
#first {
width: 300px;
float:left; /* add this */
border: 1px solid red;
}
#second {
border: 1px solid green;
overflow: hidden; /* if you don't want #second to wrap below #first */
}
const findOverflows = () => {
const documentWidth = document.documentElement.offsetWidth;
document.querySelectorAll('*').forEach(element => {
const box = element.getBoundingClientRect();
if (box.left < 0 || box.right > documentWidth) {
console.log(element);
element.style.border = '1px solid red';
}
});
};
// Execute findOverflows to find overflows on the page.
findOverflows()
let value = document.getElementById('parent').scrollWidth;
console.log(value);
Code Example |
---|
Css :: @media query css |
Css :: set visibility css |
Css :: css absolute position inside div |
Css :: rgb blue color code |
Css :: tile format css |
Css :: sass folder structure |
Css :: How do I make my background color darker in CSS |
Css :: how to make fixed position responsive |
Css :: linux remove files except |
Css :: change bg color on hover |
Css :: Sf pro font html |
Css :: letter spacing in css |
Css :: css make text closer together |
Css :: Bootstrap Carousel Custom Width |
Css :: npm registry package not found |
Css :: box shadow all sides |
Css :: css text-decoration |
Css :: ubuntu uninstall unity hub |
Css :: grid-template-rows |
Css :: progress bar bootstrap border |
Css :: css disabled hover none |
Css :: text-align css |
Css :: .txt:hover { text-decoration: underline; } |
Css :: webpack animate.css |
Css :: styling input field tailwind css |
Css :: text sliding css |
Css :: animate.css not working |
Css :: css multiple selectors |
Css :: how to hover div in css |
Css :: tailwindcss cdn v3 |