Element absolute inside div relative inside display table not show element complety - html

I'm trying show a modal in middle of the page with a width or hight dyç
I have a div with style absolute inside div with position relative, and the button not show completely,
I try to change z-index.
link of my code https://jsfiddle.net/renatoclt/qhn9v2py/3/
Here is my HTML & CSS
.ngx-utilitario-modal {
display: table;
position: fixed;
top: 0;
left: 0;
margin: 0;
padding: 0;
height: 100%;
width: 100%;
z-index: 1000;
overflow-y: auto;
margin-top: 15px;
}
.ngx-utilitario-modal .ngx-utilitario-modal-body {
display: table-cell;
vertical-align: middle;
padding: 0;
margin: 0;
width: fit-content;
height: fit-content;
overflow-y: auto;
}
.ngx-utilitario-modal .ngx-utilitario-modal-content {
background: #fff;
margin: 0 auto;
width: fit-content;
height: fit-content;
max-height: 100%;
overflow-y: auto;
padding: 15px;
}
.ngx-utilitario-modal .ngx-utilitario-modal-content .ngx-utilitario-modal-cerrar {
opacity: 1;
font-size: 18px;
position: absolute;
top: -30px;
right: -30px;
width: 30px;
height: 30px;
background-color: #fff;
border-radius: 100%;
-moz-border-radius: 100%;
box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.2);
padding: 0px;
}
.ngx-utilitario-modal-background {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: #000;
opacity: 0.75;
z-index: 900;
animation-delay: 2s;
}
<div class="ngx-utilitario-modal">
<div class="ngx-utilitario-modal-body">
<div class="ngx-utilitario-modal-content">
<div style="position: relative;">
<button type="button" class="ngx-utilitario-modal-cerrar" (click)="close()">
<span aria-hidden="true">×</span>
</button>
</div>
<div>
este es ng-content
</div>
</div>
</div>
</div>
<div class="ngx-utilitario-modal-background" [#openClose]="showModal"></div>
<div class="ngx-utilitario-modal-open"></div>
The result actually shows half of the button. I expect to show the button completely

On your .ngx-utilitario-modal .ngx-utilitario-modal-content class, you should remove overflow-y: auto;
Then you'll likely need to adjust the width of the modal to make it not be 100% so the close button isn't cut off on the sides.
Something like this:
.ngx-utilitario-modal{
display: table;
position: fixed;
top: 0;
left: 0;
margin: 0;
padding: 0;
height: 100%;
width: 100%;
z-index: 1000;
overflow-y: auto;
margin-top: 15px;
}
.ngx-utilitario-modal .ngx-utilitario-modal-body {
display: table-cell;
vertical-align: middle;
padding: 0;
margin: 0;
width: fit-content;
height: fit-content;
overflow-y: auto;
}
.ngx-utilitario-modal .ngx-utilitario-modal-content{
background: #fff;
margin: 0 auto;
width: fit-content;
height: fit-content;
max-height: 100%;
padding: 15px;
width: 80%;
}
.ngx-utilitario-modal .ngx-utilitario-modal-content .ngx-utilitario-modal-cerrar{
opacity: 1;
font-size: 18px;
position: absolute;
top: -30px;
right: -30px;
width: 30px;
height: 30px;
background-color: #fff;
border-radius: 100%;
-moz-border-radius:100%;
box-shadow:0px 1px 2px rgba(0,0,0,0.2);
padding: 0px;
}
.ngx-utilitario-modal-background {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: #000;
opacity: 0.75;
z-index: 900;
animation-delay: 2s;
}
<div class="ngx-utilitario-modal">
<div class="ngx-utilitario-modal-body">
<div class="ngx-utilitario-modal-content">
<div style="position: relative;">
<button type="button" class="ngx-utilitario-modal-cerrar" (click)="close()">
<span aria-hidden="true">×</span>
</button>
</div>
<div>
este es ng-content
</div>
</div>
</div>
</div>
<div class="ngx-utilitario-modal-background" [#openClose]="showModal"></div>
<div class="ngx-utilitario-modal-open"></div>

You can't use overflow: auto if you want this to work. Overflow would have to be set to visible.

Related

Display full image in a box

I have an input that when selecting an image it fills all this box ...
In order to completely fill this box I used 100% height and width ... in fact the image occupies the entire box, but not all of its details are visible.
Is there any way to get the image to occupy 100% but in which all your content is visible?
My problem:
Original Image
Picture inside the box (What I have)
As you can see, the image occupies the whole box (it's correct) but the problem is that the full image doesn't appear :(
Any solution?
Thanks!
My code and test
HTML
<div class="drop">
<div class="cont" *ngIf="urls.length === 0">
<div class="browse" >
Upload files
</div>
</div>
<div *ngIf="urls.length > 0">
<img [src]="urls[0]">
</div>
<input type="file" id="files" multiple (change)="detectFiles($event)" accept="image/*">
</div>
css
.drop {
margin-left: 32px;
width: 928px;
height: 696px;
border-radius: 15px;
overflow: hidden;
text-align: center;
background: white;
/* margin: auto; */
position: relative;
top: 0;
left: 0;
bottom: 0;
right: 0;
/*&:hover
cursor: pointer
background: #f5f5f5*/;
}
.drop .cont {
width: 500px;
height: 170px;
color: #8E99A5;
margin: auto;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
.drop .cont i {
font-size: 400%;
color: #8E99A5;
position: relative;
}
.drop .cont .browse {
margin: 10px 25%;
padding: 8px 16px;
border-radius: 16px;
background: #ECF2F9;
text-align: center;
font: Bold 13px/20px Noto Sans;
letter-spacing: 0;
color: #4D4F5C;
}
.drop input {
width: 928px;
height: 650px;
cursor: pointer;
background: red;
opacity: 0;
margin: auto;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
#list {
width: 100%;
text-align: left;
position: absolute;
left: 0;
top: 0;
}
#list .thumb {
height: 100%;
margin: 10px 5px 0 0;
}
img {
width: 100% !important;
height: 100% !important;
}
It's because your giving a fixed height to the parent container, what you have to add is this:
.drop{
box-sizing: border-box;
}
.drop>img{
width: 100%;
height: auto;
}
It's because of this line:
.drop {
overflow: hidden;
}
If you change it to overflow: visible/scroll it will work.
If you don't want the image to scroll you could edit the css like this:
img {
width: auto;
height: auto;
max-height: 100%;
max-width: 100%;
}
I updated. Try this.
img {
height: 100% !important;
}
.abc {
width: 100% !important;
height: 100% !important;
}
<div class="abc" *ngIf="urls.length > 0">
<img [src]="urls[0]">
</div>

Width percentage with margin and different nestings

In my webpage I have a left and a right part, they are not on the same nesting though. I want the left part to fill 25% of the page and the right part to fill the rest of the width.
Simply putting 75% isn't cutting it for me because the right part also needs a 30px right margin. A right padding won't work because my content and background-color overflows then.
Do you have an idea how to solve this?
The .left (blue) and .right(yellow) div should always perfectly meet each other and the .right needs to keep it's 30px right margin.
body {
display: block;
position: absolute;
width: 100%;
height: 100%;
top: 0;
bottom: 0;
overflow: hidden;
}
.main {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
overflow: hidden;
background-color: grey;
}
.left {
position: absolute;
top: 0;
bottom: 0;
padding-top: 0;
padding-bottom: 0;
left: 0;
width: 25%;
border-right: 1px solid #eeeeee;
background-color: lightblue;
}
.right {
position: absolute;
width: 75%;
right: 0px;
top: 45px;
bottom: 0;
/*padding-right: 30px;*/
margin-right: 30px;
background-color: yellow;
}
<body>
<div class="main">
<div class="left">TEST</div>
</div>
<div class="right">TEST</div>
</body>
It's not a good idea to create a layout using only absolute position. You may better rely on flexbox for example:
body {
height: 100vh;
margin: 0;
display: flex;
background: grey;
}
.left {
flex: 1;
border-right: 1px solid #eeeeee;
background-color: lightblue;
}
.right {
flex: 4;
margin-top: 45px;
margin-right: 30px;
background-color: yellow;
}
<div class="left">TEST</div>
<div class="right">TEST</div>
But in case you want to keep your code, you need to consider the margin within the calculation of the width:
body {
display: block;
position: absolute;
width: 100%;
height: 100%;
top: 0;
bottom: 0;
overflow: hidden;
}
.main {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
overflow: hidden;
background-color: grey;
}
.left {
position: absolute;
top: 0;
bottom: 0;
padding-top: 0;
padding-bottom: 0;
left: 0;
width: 25%;
border-right: 1px solid #eeeeee;
background-color: lightblue;
}
.right {
position: absolute;
width: calc(75% - 30px);
right: 0px;
top: 45px;
bottom: 0;
/*padding-right: 30px;*/
margin-right: 30px;
background-color: yellow;
}
<body>
<div class="main">
<div class="left">TEST</div>
</div>
<div class="right">TEST</div>
</body>

Responsive div to stay in nested div doesnt work

The button will not stay with the image when I adjust the size of the browser. I tried the position:absolutein the img div and the responsive didn't work well with the position property. Obviously the float:left doesn't work either as written in CSS.
.section6 {
margin: 0 auto;
text-align: center;
margin-top: 0;
}
.img-group img {
z-index: 2;
text-align: center;
margin: 0 auto;
border: 1px solid red;
}
div.bg-bar {
margin-top: -150px;
max-height: auto;
height: 150px;
background-color: #7290ab;
z-index: 3;
}
.section6 button {
float: left;
position: relative;
z-index: 1;
margin-top: 200px;
margin-left: 330px;
top: 40px;
}
<section class="section6">
<button>REQUEST AN INTERPRETER</button>
<div class="img-group"><img src="http://dignityworks.com/wp-content/uploads/2016/04/group-people-standing-copyspace-7235283.jpg" alt="World-class SVRS interpreters"></div>
<div class="bg-bar"></div>
</section>
See on JSFIDDLE of what I did.
You're using fixed sizing units and this is not how you make responsive pages.
If you want the button to stay in the middle, you have to position it absolutely inside the relative div.
Something like this:
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
.relative {
position: relative;
padding: 10px;
background: #0fc0fc;
animation: reduce 2s ease-in-out infinite;
height: 50px;
}
button.centered {
position: absolute;
left: 50%;
/* Kind of makes the anchor point of the element to be in the horizontal center */
transform: translateX(-50%);
}
#keyframes reduce {
0%,
100% {
width: 100%;
}
50% {
width: 50%;
}
}
<div class="relative">
<button class="centered">I'm in the middle</button>
</div>
You are better off changing the image to be a background image on that div and moving the button to be inside of it.
HTML:
<section class="section6">
<div class="img-group"><button>REQUEST AN INTERPRETER</button></div>
<div class="bg-bar"></div>
</section>
CSS:
.section6 {
margin: 0 auto;
text-align: center;
margin-top: 0;
}
.img-group {
z-index: 2;
text-align: right;
margin: 0 auto;
border: 1px solid red;
position: relative;
background: url('http://dignityworks.com/wp-content/uploads/2016/04/group-people-standing-copyspace-7235283.jpg') no-repeat;
background-size: cover;
width: 400px;
height: 370px;
}
div.bg-bar {
margin-top: -150px;
max-height: auto;
height: 150px;
background-color: #7290ab;
z-index: 3;
}
.section6 button {
position: relative;
z-index: 5;
top: 100px;
margin-right: 20px;
}
Try this:
HTML:
<section class="section6">
<div class="img-group">
<img src="http://dignityworks.com/wp-content/uploads/2016/04/group-people-standing-copyspace-7235283.jpg" alt="World-class SVRS interpreters">
<button>REQUEST AN INTERPRETER</button>
</div>
<div class="bg-bar"></div>
</section>
CSS:
.section6 {
margin: 0 auto;
text-align: center;
margin-top: 0;
}
.img-group {
position: relative;
}
.img-group img {
text-align: center;
max-width: 100%;
margin: 0 auto;
border: 1px solid red;
}
.img-group button {
display: block;
position: absolute;
z-index: 10;
margin-left: -75px;
top: 50%;
left: 50%;
max-width: 100%;
}
div.bg-bar {
margin-top: -150px;
max-height: auto;
height: 150px;
background-color: #7290ab;
}

Why i can not set image style height 100% for height as same as div container?

Why i can not set image style height 100% for height as same as div container ?
When i tried to test code it's will be show like this.
https://i.imgur.com/Q1MGP0Z.png
I want to show image like this.
https://i.imgur.com/GeLUUCo.png
with class name img_look style height: 100%; How can i do ?
.li_look{
padding: 0px;
margin: 0;
position: relative;
width: 25%;
border-right: 3px solid #fff;
margin-right: -3px;
z-index: 11;
float: left;
list-style: none;
color: #333;
font-size: 19px;
background: #fff;
}
.div_1{
float: none;
margin: 0;
width: 100%;
height: 197.207px;
display: block;
position: relative;
}
.a_tag{
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
height: 100%;
margin-left: auto;
margin-right: auto;
overflow: hidden;
display: block;
cursor: pointer;
}
.div_2{
transform: translateX(-50%);
left: 50%;
top: 0;
background-color: transparent;
display: block;
position: absolute;
}
.img_look{
height: 100%;
display: block;
margin-left: auto;
margin-right: auto;
max-width: unset;
}
<ul>
<li class="li_look">
<div class="div_1">
<a href="#" class="a_tag">
<div class="div_2">
<img src="https://i2.wp.com/www.thisblogrules.com/wp-content/uploads/2010/02/man-and-bear-bath.jpg?resize=550%2C356" class="img_look">
</div>
</a>
</div>
</li>
</ul>
The problem lies with the parent container of the img tag. Since, there is no height defined for it, you cannot use 100% in relation to the parent container. Define a height as shown below in my code for .div_2. And it will work fine.
.li_look{
padding: 0px;
margin: 0;
position: relative;
width: 25%;
border-right: 3px solid #fff;
margin-right: -3px;
z-index: 11;
float: left;
list-style: none;
color: #333;
font-size: 19px;
background: #fff;
}
.div_1{
float: none;
margin: 0;
width: 100%;
height: 197.207px;
display: block;
position: relative;
}
.a_tag{
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
height: 100%;
width:100%;
margin-left: auto;
margin-right: auto;
overflow: hidden;
display: block;
cursor: pointer;
}
.div_2{
transform: translateX(-50%);
left: 50%;
top: 0;
background-color: transparent;
display: block;
position: absolute;
height:100%;
}
.img_look{
height: 100%;
display: block;
margin-left: auto;
margin-right: auto;
max-width: unset;
}
<ul>
<li class="li_look">
<div class="div_1">
<a href="#" class="a_tag">
<div class="div_2">
<img src="https://i2.wp.com/www.thisblogrules.com/wp-content/uploads/2010/02/man-and-bear-bath.jpg?resize=550%2C356" class="img_look">
</div>
</a>
</div>
</li>
</ul>
Your image IS the same size as your div, but your div ISN'T the same size as the a tag that hold it. since your a has overflow:hidden; you can't see that your div is actually bigger.
you cant just add height:100%; or width:100%; to your div, but keep your image dimensions the same.
Also : that feels really wrong don't you think ?
height: 197.207px;
I think You Need This https://jsfiddle.net/wqhch5et/ view full screen mode.
You need to change position: absolute; to position: fixed; in div_2
.li_look{
padding: 0px;
margin: 0;
position: relative;
width: 25%;
border-right: 3px solid #fff;
margin-right: -3px;
z-index: 11;
float: left;
list-style: none;
color: #333;
font-size: 19px;
background: #fff;
}
.div_1{
float: none;
margin: 0;
width: 100%;
height: 197.207px;
display: block;
position: relative;
}
.a_tag{
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
height: 100%;
margin-left: auto;
margin-right: auto;
overflow: hidden;
display: block;
cursor: pointer;
}
.div_2{
transform: translateX(-50%);
left: 50%;
top: 0;
background-color: transparent;
display: block;
position: fixed;
}
.img_look{
height: 100%;
display: block;
margin-left: auto;
margin-right: auto;
max-width: unset;
}
<ul>
<li class="li_look">
<div class="div_1">
<a href="#" class="a_tag">
<div class="div_2">
<img src="https://i2.wp.com/www.thisblogrules.com/wp-content/uploads/2010/02/man-and-bear-bath.jpg?resize=550%2C356" class="img_look">
</div>
</a>
</div>
</li>
</ul>

how to fix model popup on center of the page

i am using model popup on the page. i have table with 200 rows on the page. and when i click each row model popup open. but when i scroll down on the table and click on row. model popup open upside on the page. i want it to open always on the center of the page even i scroll down on the table.
my css is
.modal {
position: absolute;
top: 30px;
right: 100px;
bottom: 0;
left: 0;
z-index: 10040;
overflow: auto;
overflow-y: auto;
}
Here is an example (Live: http://ud.ht/gLlF):
<div class="modal" role="dialog" style="display: block;">
<div class="modal-parent">
<div class="modal-container">
<div class="modal-contnet">
<span class="modal-text" role="dialog-message">This is text</span>
</div>
</div>
</div>
</div>
Here is the css:
.modal {
z-index: 10000;
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color: rgba(0,0,0,.7);
font-family: Tahoma;
overflow: auto;
overflow-y: scroll;
overflow-x: auto;
display: none;
}
.modal-parent {
display: table;
height: 100%;
table-layout: fixed;
width: 100%;
}
.modal-container {
display: table-cell;
text-align: center;
vertical-align: middle;
width: 100%;
}
.modal-contnet {
width: 450px;
display: inline-block;
position: relative;
text-align: right;
background-color: #eee;
margin: 20px 0;
}
.modal-text {
padding: 20px 25px;
font-family: Tahoma;
font-size: 12px;
display: block;
direction: rtl;
text-align: center;
line-height: 20px;
}
.modal {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: block;
z-index: 999;
}
.modal-body {
margin-top: 30px;
margin-left: auto;
margin-right: auto;
width: 600px;
min-height: 20px;
}
<div class="modal">
<div class="modal-body">
<p>Your content here</p>
</div>
</div
try this, hopes this helps you