want to make only close button overflow visible inside a modal - html

I want to display full close button/text while maintaining modal's position:fixed and overflow:scroll
if i replace overflow:scroll with overflow:visible it appears fully but stops scrolling
<div id="root_component">
<div class="modal" >
<a class="modal-close btn-floating btn-small
waves-effect waves-light right clearfix">
<i class="material-icons">cancel</i>
</a>
<div class="modal-content"></div>
</div>
</div>
.modal {
width: 80% !important;
overflow-y: scroll;
z-index: 1003;
display: block;
opacity: 1;
transform: scaleX(1) scaleY(1);
position: fixed;
padding: 0;
margin: auto;
border-radius: 2px;
}
#root_component .clearfix {
position: absolute;
right: -16px;
top: -16px;
z-index: 100;
}
screenshot attached

Just wrap your .parent div in another .parent-wrapper div and take your .child div out of .parent. This works :
.grand-parent {
position: relative;
height: 10px;
width: 10px;
background: red;
top: 10px;
}
.parent-wrapper {
height: 150px;
width: 60px;
position: fixed;
}
.parent {
height: 150px;
width: 60px;
overflow: scroll;
background: blue;
}
.child {
overflow: visible;
position: absolute;
top: 10px;
left: 20px;
background: yellow;
}
<div class="grand-parent">
<div></div>
<div class="parent-wrapper">
<div class="parent">adfasdf<br> asdf
<br> asdf
<br> adsf
<br> asdfasd
<br> fads
<br> fdsaf
<br> sadfasd
<br> afdsf
</div>
<div class="child"> close</div>
</div>
</div>

If this is what you're trying to do, you have to make the .child class position fixed. The close button/text position will be fixed irrespective of scroll on the divs.
.grand-parent {
position: relative;
height: 10px;
width: 10px;
background: red;
top: 10px;
}
.parent {
height: 150px;
width: 60px;
overflow: scroll;
background: blue;
position: fixed;
}
.child {
overflow: visible;
position: fixed;
top: 20px;
left: 30px;
background: yellow;
}
<div class="grand-parent">
<div></div>
<div class="parent">adfasdf<br> asdf
<br> asdf
<br> adsf
<br> asdfasd
<br> fads
<br> fdsaf
<br> sadfasd
<br> afdsf
<div class="child"> close</div>
</div>
</div>

Related

Adding a vertically scrollable item inside a horizontal carousel

I'm building a customised horizontal carousel, where in I want to display some items which are vertically scroll-able.
Code I've tried so far:
html
<div class="carousel">
<div class="c-item">Item-1</div>
<!-- to be displayed vertically -->
<div class="abs">
<div class="a-item">Abs Item-1.1</div>
<div class="a-item">Abs Item-1.2</div>
<div class="a-item">Abs Item-1.3</div>
</div>
<div class="c-item margin">Item-2</div>
<!-- to be displayed vertically -->
<div class="abs">
<div class="a-item">Abs Item-2.1</div>
<div class="a-item">Abs Item-2.2</div>
<div class="a-item">Abs Item-2.3</div>
</div>
</div>
<div class="other">
Other div
</div>
css
.carousel{
color: #FFF;
white-space: nowrap;
overflow-x: auto;
overflow-y: hidden;
position: initial;
.c-item{
display: inline-block;
width: 35%;
background: #000;
height: 100px;
&.margin{
//margin-left: 35%;
}
}
.abs{
background: #444;
display: inline-block;
vertical-align: top;
width: 35%;
max-height: 180px;
overflow-y: auto;
.a-item{
height: 100px;
border: 1px solid #000;
}
}
}
.other{
background: yellow;
}
Result:
(codepen)
The problem here is: I want the other div to start just below the item-1; meaning that the vertically scrolled div should be overlapping the other div and the carousel height should be fixed at 100px. I tried using position: absolute for the .abs div but then that div doesn't move on scrolling the carousel.
Desired output will look like this:
A flexbox solution
Each item is 33.33% wide and 100px high. The items inside .multiple are also 100px high.
.multiple has position: relative and overflow-y: auto. The items inside have position: absolute.
Hint: Container -> position: relative, items inside -> position: absolute. That's how it works.
top: (100 * n)px for each <div> inside .item.multiple. n is the index of the <div> inside .item.multiple, starting with 0.
The HTML structure has been changed
* {
box-sizing: border-box;
}
body {
margin: 0;
}
.carousel {
display: flex;
width: 100vw;
overflow-x: auto;
color: white;
}
.carousel>.item {
flex: 1 0 33.33%;
//margin-right: 5px;
}
.carousel>.item:nth-child(odd) {
background: black;
}
.carousel>.item:nth-child(even) {
background: darkgrey;
}
.carousel>.item,
.carousel>.item.multiple>div {
height: 100px;
}
.carousel>.item.multiple {
position: relative;
overflow-y: auto;
}
.carousel>.item.multiple>div {
position: absolute;
width: 100%;
}
.carousel>.item.multiple>div:nth-child(2) {
top: 100px;
}
.carousel>.item.multiple>div:nth-child(3) {
top: 200px;
}
/* And so on ...
.carousel>.item.multiple>div:nth-child(...) {}
*/
<div class="carousel">
<div class="item">
<div>Item-1</div>
</div>
<div class="item multiple">
<div>Item-1.1</div>
<div>Item-1.2</div>
<div>Item-1.3</div>
</div>
<div class="item">
<div>Item-2</div>
</div>
<div class="item multiple">
<div>Item-2.1</div>
<div>Item-2.2</div>
<div>Item-2.3</div>
</div>
</div>
<div class="other">
Other div
</div>
Your desired result mean making the child overlap the parent, and i don't think that's possible. BUT you can "hack" this by wrapping the .carousel with another div (.demo it this general example), so the results will be something like this:
.demo {overflow: visible; height: 100px;}
.carousel {
color: #FFF;
white-space: nowrap;
overflow-x: auto;
overflow-y: hidden;
position: initial;
}
.carousel .c-item {
display: inline-block;
width: 35%;
background: #000;
height: 100px;
}
.carousel .abs {
background: #444;
display: inline-block;
vertical-align: top;
width: 35%;
max-height: 180px;
overflow-y: auto;
}
.carousel .abs .a-item {
height: 100px;
border: 1px solid #000;
}
.other {
background: yellow;
height: 200px;
}
<div class="demo">
<div class="carousel">
<div class="c-item">Item-1</div>
<div class="abs">
<div class="a-item">Abs Item-1.1</div>
<div class="a-item">Abs Item-1.2</div>
<div class="a-item">Abs Item-1.3</div>
</div>
<div class="c-item margin">Item-2</div>
<div class="abs">
<div class="a-item">Abs Item-2.1</div>
<div class="a-item">Abs Item-2.2</div>
<div class="a-item">Abs Item-2.3</div>
</div>
</div>
</div>
<div class="other">
Other div
</div>
As you can see from the snippet the scroll-x doesn't show - yet it exist. You can click one of the .carousel item and scroll them right and left.
Since it's not obvious that the .carousel is scrolling, you can add extra buttons to scroll it:
.demo {overflow: visible; height: 100px;z-index: 3;}
.carousel {
color: #FFF;
white-space: nowrap;
overflow-x: auto;
overflow-y: hidden;
position: initial;
}
.carousel .c-item {
display: inline-block;
width: 35%;
background: #000;
height: 100px;
}
.carousel .abs {
background: #444;
display: inline-block;
vertical-align: top;
width: 35%;
max-height: 180px;
overflow-y: auto;
}
.carousel .abs .a-item {
height: 100px;
border: 1px solid #000;
}
.other {
background: yellow;
height: 200px;
}
<div class="demo">
<button onclick="document.querySelectorAll('.carousel')[0].scrollLeft += 20;" style="position: fixed; top: 50%; right: 0;">L</button>
<button onclick="document.querySelectorAll('.carousel')[0].scrollLeft -= 20;" style="position: fixed; top: 50%; left: 0;">R</button>
<div class="carousel">
<div class="c-item">Item-1</div>
<div class="abs">
<div class="a-item">Abs Item-1.1</div>
<div class="a-item">Abs Item-1.2</div>
<div class="a-item">Abs Item-1.3</div>
</div>
<div class="c-item margin">Item-2</div>
<div class="abs">
<div class="a-item">Abs Item-2.1</div>
<div class="a-item">Abs Item-2.2</div>
<div class="a-item">Abs Item-2.3</div>
</div>
</div>
</div>
<div class="other">
Other div
</div>
Hope that helps!
You have to play with position check snippet.
* {
box-sizing: border-box;
}
body {
margin: 0;
}
.carousel {
display: flex;
width: 100vw;
overflow-x: auto;
color: white;
}
.carousel>.item {
flex: 1 0 33.33%;
//margin-right: 5px;
}
.carousel>.item:nth-child(odd) {
background: black;
}
.carousel>.item:nth-child(even) {
background: darkgrey;
}
.carousel>.item,
.carousel>.item.multiple>div {
height: 100px;
}
.carousel>.item.multiple {
position: relative;
overflow-y: auto;
height: 200px;
}
.carousel>.item.multiple>div {
position: absolute;
width: 100%;
}
.carousel>.item.multiple>div:nth-child(2) {
top: 100px;
}
.carousel>.item.multiple>div:nth-child(3) {
top: 200px;
}
.other {
position: absolute;
z-index: -1;
top: 100px;
width: 100%;
background: green;
height: 117px;
}
/* And so on ...
.carousel>.item.multiple>div:nth-child(...) {}
*/
<div class="carousel">
<div class="item">
<div>Item-1</div>
</div>
<div class="item multiple">
<div>Item-1.1</div>
<div>Item-1.2</div>
<div>Item-1.3</div>
</div>
<div class="item">
<div>Item-2</div>
</div>
<div class="item multiple">
<div>Item-2.1</div>
<div>Item-2.2</div>
<div>Item-2.3</div>
</div>
</div>
<div class="other">
Other div
</div>

Shifted overflowing div Mozilla Firefox Margin

I want to code a shifted div as here:
https://codepen.io/anon/pen/VQQdaL
Relevant css:
.wrap {
display: flex;
margin: 0 auto;
max-width: 1000px;
width: 100%;
}
.box {
position: relative;
flex-shrink: 0;
background: #fff;
margin-bottom: 5%;
width: 50%;
}
.image {
flex-shrink: 0;
margin-top: 5%;
margin-left: -5%;
width: 55%;
background: linear-gradient(135deg, #fed2db, #212353);
}
this works for me just fine in Chrome/Safari but not in Firefox. Is there something I am missing?
This is what it should look like:
This is what it looks like in Firefox:
.section {
background: black;
padding: 4em 0;
}
.wrap {
display: flex;
margin: 0 auto;
max-width: 1000px;
width: 100%;
}
.box {
position: relative;
flex-shrink: 0;
background: #fff;
margin-bottom: 5%;
width: 50%;
}
.image {
flex-shrink: 0;
top: 5%;
margin-left: -5%;
width: 55%;
background: linear-gradient(135deg, #fed2db, #212353);
}
<div class="section">
<div class="wrap">
<div class="box">
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</div>
<div class="image"></div>
</div>
</div>
The problem seems primarily due to the lack of absolute height. I couldn't produce a clean single reason for the behavior, but in the meantime, I recreated the intended result in JSFiddle. Hope this helps.
JSFiddle code:
.section {
background: black;
padding: 4em 0;
}
.wrap {
display: flex;
margin: 0 auto;
max-width: 1000px;
width: 100%;
}
.box {
position: absolute;
height: 100px;
flex-shrink: 0;
background: blue;
margin-bottom: 5%;
width: 50%;
}
.image {
position: relative;
height: 100px;
flex-shrink: 0;
background: green;
margin-top: 20px;
margin-left: 45%;
width: 55%;
background: linear-gradient(135deg, #fed2db, #212353);
}
<div class="section">
<div class="wrap">
<div class="box">
<br>
<br>
<br>
<br>
<br>
</div>
<div class="image"></div>
</div>
</div>

Centering a <div> inside a popup <div>

I'm having an issue figuring out how to center a <div> within a <div> that popped up after clicking a button.
Not my example, but similar. HTML:
<div class="popup">
<div class="options">
<div class="option">
<span id="1">1</span>
</div>
<div class="option">
<span id="2">2</span>
</div>
<div class="option">
<span id="3">3</span>
</div>
<div class="option">
<span id="4">4</span>
</div>
</div>
<p></p>
<div id="persona">
<span id="5">5</span>
</div>
</div>
CSS:
.popup
{
background-color: #e3ddd1;
position: absolute;
left: 10%;
top: 10%;
height: 400px;
width: 500px;
}
#persona
{
margin-left: auto;
margin-right: auto;
}
The overlay is just used to fade out the background, and then the popup appears on top of it.
The issue is in the #persona block, how do I get it so that <div id="persona"> is centered within the popup?
Try this CSS. Working Demo
.overlay
{
background-color: rgba(0, 0, 0, 0.8);
display: block;
position: absolute;
bottom: 0;
left: 0;
right: 0;
top: 0;
}
.popup
{
background-color: #e3ddd1;
display: table;
position: absolute;
left: 50%;
top: 50%;
margin-left: -500px;
margin-top: -200px;
height: 400px;
width: 1000px;
}
#persona
{
display: table-cell;
margin-left: auto;
margin-right: auto;
text-align: center;
vertical-align: middle;
}

push down child div out of parent div

I have a html markup like this
<div class="relative">
<div id="absolute">
<p>absolute content</p>
</div>
<p>Parent div</p>
</div>
<div>outer content</div>
and css is
.relative {
position: relative;
width: 600px;
height: 400px;
background: #ddd;
}
#absolute {
position: absolute;
top: 120px;
right: 0;
width: 300px;
height: 200px;
background: #eee;
}
Now for some reason I want to take out the child div (id=absolute) out of its parent (id=relative) while pushing down whatever content in below the parent div.
This is what I want to get,
any help is appreciated
Try this - http://jsfiddle.net/8eXEE/
HTML
<div class="relative">
<div id="absolute">
<p>absolute content</p>
</div>
<p>Parent div</p>
</div>
<div style="background-color:#ff0000; width:400px; height:100px; position: relative; top:200px;">outer content</div>
CSS
.relative {
position: relative;
width: 600px;
height: 400px;
background: #ddd;
}
#absolute {
position: absolute;
bottom: 0px;
left: 0px;
width: 300px;
height: 200px;
background: #eee;
margin-bottom: -200px;
}
If your #absolute divs height does not dynamically changes (i.e. remains 200px always)
The markup
<div class="relative">
<div id="absolute">
<p>absolute content</p>
</div>
<p>Parent div</p>
</div>
<div id="outer">outer content</div>
The CSS
.relative {
position: relative;
width: 600px;
height: 400px;
background: #ddd;
}
#absolute {
position: absolute;
top: 100%;
left: 0;
width: 300px;
height: 200px;
background: #eee;
}
#outer {
position:relative;
margin-top:200px;
background:blue;
}
Here is the plunker , you can play with it.

Mobile Safari: Image with 100% height not visible in absolute positioned container

Demo: http://codepen.io/malte/pen/kDlbt
I am using an absolute positioned wrapper to center an image in a thumbnail frame. (Only) On mobile safari, the image won't be displayed. if you inspect the .image-pos container you'll see that the height is properly set to its parent's size. applying a fixed px height to it will make the image show up... Does anyone know how to fix that?
It's working on any Desktop browser...
HTML:
<div class="wrapper">
<div class="thumb-grid">
<div class="thumb">
<a href="#" class="image">
<div class="image-pos">
<img src="http://images.weserv.nl/?url=static.living.is/gallery/original/5184f3631034bcdf16bd4d37c341928e.jpg&il&w=600" />
</div>
</a>
<div class="details">
<h5>Image Title</h5>
</div>
</div>
<div class="thumb">
<a href="#" class="image">
<div class="image-pos">
<img src="http://images.weserv.nl/?url=static.living.is/gallery/original/5184f3631034bcdf16bd4d37c341928e.jpg&il&w=600" />
</div>
</a>
<div class="details">
<h5>Image Title</h5>
</div>
</div>
<div class="thumb">
<a href="#" class="image">
<div class="image-pos">
<img src="http://images.weserv.nl/?url=static.living.is/gallery/original/016e551de2f53d58e7f4acd68279e6a1.JPG&il&w=600" />
</div>
</a>
<div class="details">
<h5>Image Title</h5>
</div>
</div>
</div>
</div>
CSS:
.wrapper {
width: 600px;
margin: 30px auto 0
}
.thumb-grid {
text-align: justify;
}
.thumb-grid:after {
content: '';
display: inline-block;
width: 100%;
}
.thumb {
position: relative;
display: inline-block;
width: 31.5%;
height: 0;
padding-top: 29%;
margin-bottom: 6%;
}
.image {
height: 73%;
overflow: hidden;
position: absolute;
text-align: center;
top: 0;
width: 100%;
vertical-align: top;
display: block;
border: 1px solid #eee;
}
.image-pos {
height: 100%;
left: 50%;
margin-left: -300px;
position: absolute;
text-align: center;
width: 600px;
}
.image-pos img {
height: 100%;
max-height: 100%;
min-height: 100%;
max-width: none;
width: auto;
display: inline;
border: 0;
}
.details {
height: 27%;
position: absolute;
top: 73%;
}
.details h5 {
margin: 0;
padding-top: 5px;
}
Demo: http://codepen.io/malte/pen/kDlbt