I've got a div that I want to position partially off-screen like so:
div{ position: absolute; height: 100px; width: 100px; right: -50px; top: 50px; }
But this increases the size of the page, allowing it to be scrolled to the right. Is there any way to keep half of this div hidden and prevent scrolling to view it?
To hide an element in a responsive layout, we need to use the CSS display property set to its "none" value along with the @media rule. The content of the second <p> element having a "hidden-mobile" class will be hidden on devices smaller than 767px.
You can hide an element in CSS using the CSS properties display: none or visibility: hidden. display: none removes the entire element from the page and mat affect the layout of the page. visibility: hidden hides the element while keeping the space the same.
CSS Display Property. Each element has a default display value like inline-block , block , table ..etc. To hide an element with the display property, we should use display: none . When an element is hidden with display: none , all of its descendants will be removed along with it.
Style display property is used to hide and show the content of HTML DOM by accessing the DOM element using JavaScript/jQuery. To hide an element, set the style display property to “none”. document. getElementById("element").
Yes, just create an enclosing div with overflow: hidden
, like this:
.outer { overflow: hidden; position: relative; } .inner { position: absolute; height: 100px; width: 100px; right: -50px; top: 50px; }
<div class="outer"> <div class="inner"> CONTENT </div> </div>
Example: http://jsfiddle.net/Uj3eQ/
Just add overflow:hidden
to the css. That should do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With