How to overlap one div on another div using HTML and CSS - html

I tried z-index :-1 and position:absolute both didn't worked.
How to fix issue.
Are there any other alternatives for overlapping.
<div *ngIf="allFiltersData.length > 0">
<div style="width: 100%;">
<div id="{{controls.fieldName}}_Text" style="border-style: groove;font-style: 14px;border-radius:3px;height: 100%;word-wrap: break-word;padding-left:10px;padding-top:4px;padding-bottom: 4px;font-size: 14px;color:#333333;vertical-align: middle;" tabindex=0 (click)="showList(controls.fieldDisplayName)" class="accordion">Select {{controls.fieldDisplayName}}</div>
<div name='htmlMultiSelect' style="overflow:auto;border-style: groove;width: 300px;background-color: white; position: absolute;height:auto;max-height: 200px; white-space: nowrap;display: none;" id="{{controls.fieldDisplayName}}">
<div style=" padding-left: 10px;padding-top: 10px;padding-bottom: 20px;">
<input type="checkbox" (click)="selectAllForMultiSelect(controls,$event,tab.name)" style="width: 20px;height: 20px;vertical-align:middle;" id="{{controls.fieldName}}_SelectAll">
<input name="{{controls.fieldName}}" (keypress)="multiSelectSearch($event,tab.name,controls)" id="{{controls.fieldDisplayName}}_{{tab.name}}_Search" style="width: 200px;height: 30px;vertical-align:middle;" type="text">
</div>
<div name="customMultiSelectItems" style="padding-top: 5px;padding-left: 10px;" *ngFor="let val of fetchFilterValues(controls.fieldName,true)">
<input type="checkbox" (click)="setSelectedData(controls.fieldControlType, controls.fieldName, {id:val.value.id,name:val.value.name},controls.dependentFilterName,$event,controls.fieldDisplayName,tab.name)" style="width: 20px;height: 20px;vertical-align:middle;" id="{{val.value.id}}_{{controls.fieldName}}_{{tab.name}}" name={{val.value.name}}_{{controls.fieldName}}_{{tab.name}}>
<label tabindex=0 style="font-size:14px;color: #333333;vertical-align:middle;" for={{val.value.id}}_{{tab.name}}> {{val.value.name}}</label>
</div>
<br>
</div>
</div>
</div>
<div id="OverlapThisSection" style="position:absolute">
<div>
</div>
</div>
I'm using above code.
Div with id OverlapThisSection needs to be overlapped. I had set Div with name htmlMultiSelect to position:absolute
Div with id OverlapThisSection not getting overlapped by another Div above to it.
Update 1:
Currently I'm getting view as below.
Actually I'm using primeng dropdown inside OverlapThisSection div.
<p-dropdown> not getting overlapped by it's top div.
How to fix this issue.

I see this 2 different divs, so you can use position:absolute; and top:20px; to the second div.
#OverlapThisSection {
margin: 10px;
position: absolute;
top: 30px;
background-color: green;
}
<div *ngIf="allFiltersData.length > 0">
<div style="width: 100%; height:50px;">
<div id="{{controls.fieldName}}_Text" style="border-style: groove;font-style: 14px;border-radius:3px;height: 100%;word-wrap: break-word;padding-left:10px;padding-top:4px;padding-bottom: 4px;font-size: 14px;color:#333333;vertical-align: middle;" tabindex=0
(click)="showList(controls.fieldDisplayName)" class="accordion">Select {{controls.fieldDisplayName}}</div>
<div name='htmlMultiSelect' style="overflow:auto;border-style: groove;width: 300px;background-color: white; position: absolute;height:auto;max-height: 200px; white-space: nowrap;display: none;" id="{{controls.fieldDisplayName}}">
<div style=" padding-left: 10px;padding-top: 10px;padding-bottom: 20px;">
<input type="checkbox" (click)="selectAllForMultiSelect(controls,$event,tab.name)" style="width: 20px;height: 20px;vertical-align:middle;" id="{{controls.fieldName}}_SelectAll">
<input name="{{controls.fieldName}}" (keypress)="multiSelectSearch($event,tab.name,controls)" id="{{controls.fieldDisplayName}}_{{tab.name}}_Search" style="width: 200px;height: 30px;vertical-align:middle;" type="text">
</div>
<div name="customMultiSelectItems" style="padding-top: 5px;padding-left: 10px;" *ngFor="let val of fetchFilterValues(controls.fieldName,true)">
<input type="checkbox" (click)="setSelectedData(controls.fieldControlType, controls.fieldName, {id:val.value.id,name:val.value.name},controls.dependentFilterName,$event,controls.fieldDisplayName,tab.name)" style="width: 20px;height: 20px;vertical-align:middle;"
id="{{val.value.id}}_{{controls.fieldName}}_{{tab.name}}" name={{val.value.name}}_{{controls.fieldName}}_{{tab.name}}>
<label tabindex=0 style="font-size:14px;color: #333333;vertical-align:middle;" for={{val.value.id}}_{{tab.name}}> {{val.value.name}}</label>
</div>
<br>
</div>
</div>
</div>
<div id="OverlapThisSection" style="position:absolute">Second div content
<div>
</div>
</div>
Or another simple example, you don't have to use z-index for this:
.first {
height: 100px;
width: 100px;
background-color: red;
}
.second {
margin: 10px;
position: absolute;
top: 10px;
height: 80px;
width: 80px;
background-color: green;
}
<div class="first">
</div>
<div class="second">
</div>

Related

Why my interface look differently in browser and google device toolbar?

my interface in Google chrome browser (Is normal, I set it like this)
But when I click the inspect and click google device toolbar, the interface look like:
.btn {
position: absolute;
top: 85%;
left: 50%;
transform: translate(-50%, -50%);
cursor: pointer;
}
.div_hover {
background-color: #F9F7F2;
}
<div style="width: 80%; margin: auto;">
<div class="div_hover" style="width: 473px; height: 200px; margin: auto;">
<p style="font-size: 18px;">Dear Customer</p>
<hr>
<p style="font-size: 11px">Welcome.......</p>
<hr>
<p style="font-size: 11px">bla..bla...</p>
<hr>
</div>
<div style="width: 49%; margin: auto; position: relative;">
<img src="https://www.rspcasa.org.au/wp-content/uploads/2019/01/Adopt-cat-mobile-banner-600x300-fit-constrain-q70-mobile_banner_image.jpg">
<form action="https://www.google.com/">
<input type="image" src="https://www.freepngimg.com/thumb/download_now_button/25399-6-download-now-button-thumb.png" class="btn" />
</form>
</div>
</div>
How can I make it both same?
Well, you are currently setting the div have the width of 49% but <img> doesn't have any width set. That is causing the image to be its original size. If you want to display the image in the same way for different screen width, you should do something like this:
<div style="width: 80%; margin: auto;">
<div class="div_hover" style="width: 473px; height: 200px; margin: auto;">
<p style="font-size: 18px;">Dear Customer</p>
<hr>
<p style="font-size: 11px">Welcome.......</p>
<hr>
<p style="font-size: 11px">bla..bla...</p>
<hr>
</div>
<div style="width: 473px; margin: auto; position: relative;">
<img width="100%" src="https://www.rspcasa.org.au/wp-content/uploads/2019/01/Adopt-cat-mobile-banner-600x300-fit-constrain-q70-mobile_banner_image.jpg">
<form action="https://www.google.com/">
<input type="image" src="https://www.freepngimg.com/thumb/download_now_button/25399-6-download-now-button-thumb.png" class="btn" />
</form>
</div>
</div>
As you see, don't give the custom width to the second child div. If you have to give the width as 49% for second div, then give the width for <img> as well.
https://jsfiddle.net/2epL85r1/

HTML5 Forms Action bahavior

Okay I'm trying to pass parameters like this link here using form tag in HTML
https://pyramisaegypt.seebooking.com/#/booking-engine/room-list?property_id=445586&checkin=2018-11-22&checkout=2018-11-23&noOfAdults=1&noOfChildren=1&noOfRooms=1&promo_code=
but for some reason it always becomes this after i hit submit
https://pyramisaegypt.seebooking.com/?property_id=445586&checkin=2018-11-22&checkout=2018-11-23&noOfAdults=1&noOfChildren=1&noOfRooms=1&promo_code=#/booking-engine/room-list
Notice that whatever is after the hash and behind the question mark gets transferred at the end of the url
The page url is http://pyramisaegypt.com/test-page/
My code is
<form id="reservation-widget-wrap-form-element" style="background-color: #f0f0f0; color: #777; padding: 10px; padding-right: 5px; margin-bottom: 20px;" action="https://pyramisaegypt.seebooking.com/#/booking-engine/room-list" method="get" target="_blank">
<div id="children-wrap" style="width: 20%; display: inline-block">
<div class="caption">Hotels</div>
<p><select id="reservation-widget-hotels" style="width: 100%;height: 32px;padding-left: 5px;margin-bottom: 0px;" name="property_id"><option value="547027">Pyramisa Cairo Suites Hotel</option><option value="568389">Pyramisa Sahl Hasheesh Resort</option><option value="31070">Pyramisa Sharm El Sheikh Resort</option><option value="35520">Pyramisa Isis Luxor Resort</option><option value="445586">Pyramisa Isis Island Aswan Resort</option><option value="450628">Pyramisa Isis Corniche Aswan Resort</option></select></p>
</div>
<div id="check-in-wrap" style="display: inline-block; /* background: white;">
<div class="caption">Check-in date</div>
<p><input id="reservation-widget-checkin" class="hasDatepicker" style="width: 125px;height: 50%;" name="checkin" type="date"></p>
</div>
<div id="check-out-wrap" style="display: inline-block; padding: 5px;">
<div class="caption">Check-out date</div>
<p><input id="reservation-widget-checkout" class="hasDatepicker" style="width: 125px;height: 50%;" name="checkout" type="date"></p>
</div>
<div id="adults-wrap" style="display: inline-block;">
<div class="caption">Adults</div>
<p style="width: 100px;"><select id="reservation-widget-adults" style="display: inline-block; width: 121.4px; height: 50%;" name="noOfAdults"><option value="1">1</option><option value="2">2</option></select></p>
</div>
<div id="children-wrap" style="display: inline-block;padding: 5px;width: 100px;">
<div class="caption">Children</div>
<p style="
width: 100px;
"><select id="reservation-widget-children" style="display: inline-block; width: 121.4px; height: 50%;" name="noOfChildren"><option value="0">0</option><option value="1">1</option><option value="2">2</option></select></p>
</div>
<div class="caption">Number of Rooms</div>
<p style="
width: 100px;
"><select id="reservation-widget-children" style="display: inline-block; width: 121.4px; height: 50%;" name="noOfRooms"><option value="0">0</option><option value="1">1</option><option value="2">2</option></select></p>
</div>
<div id="children-wrap" style="display: inline-block;padding: 5px;width: 100px; margin-left: 1%;">
<div class="caption">Promo Code</div>
<p style="width: 100px;">
<input type="text" style="width: 100%;" name="promo_code">
</p>
</div>
<p style="display: inline-block; width: 20%; margin-bottom: 0px; margin-left: 2%;"><button id="submit-button" type="submit" style="
background: #b01c30;
width: 90%;
border-radius: 6px;
height: 35px;
border: none;
">Online Reservation</button></p>
</form>
i tried every solution out there to change the behavior of the hash in the action of the form but nothing seemed to be working so far.
Perhaps you should look at how a URL is formed. Anything after a # is not sent to the server as it refers to an anchor on the page. Therefore a "GET" form will always strip out those bits.

Center input horizontally in div

I know this has been answered 100 times, but none of the existing solutions seem to work for me.
I want to center an input field horizontally in a div. Why is horizontal centering such a pain?!?!? The parent div may change in size based on screen size, so margin percentages don't work.
HTML
<div class="select" id="avatar">
<h4>Please enter your name.</h4>
<!-- Object i want to center-->
<div class="input-group">
<input type="text" class="form-control text-center" id="playerName">
</div>
<h4>And Select Your Ship</h4>
<img class="avatars" id="ship1" src="images/spaceship1.png">
<img class="avatars" id="ship2" src="images/spaceship2.png">
<img class="avatars" id="ship3" src="images/spaceship3.png">
<img class="avatars" id="ship4" src="images/spaceship4.png">
<button class="btn" id="submitPlayer">Submit</button>
</div>
parents CSS
.select {
background-color: white;
z-index: 200;
padding: 0px 15px 0px 15px;
text-align: center;
font-family: 'Krona One', sans-serif;
border: medium dashed green;
margin-left: 25%;
margin-right: 25%;
}
I also want to center this one, and I assume it will be the same solution, but it has no parent, besides body.
<div class="input-group">
<input class="text-center" type="text" id="word">
</div>
Why not use Bootstrap's center-block class..
<div class="input-group center-block">
<input class="center-block" type="text" id="word">
</div>
http://www.bootply.com/sTboTk5CvU
inputs and button are like img, you can display them as block and use margin:auto; so they stand alone and in the middle without using 100% of the width/space avalaible :
.select {
background-color: white;
z-index: 200;
padding: 0px 15px 0px 15px;
text-align: center;
font-family: 'Krona One', sans-serif;
border: medium dashed green;
margin-left: 25%;
margin-right: 25%;
}
button.btn#submitPlayer {
display: block;
margin: auto;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="select" id="avatar">
<h4>Please enter your name.</h4>
<!-- Object i want to center-->
<div class="input-group">
<input type="text" class="form-control text-center" id="playerName">
</div>
<h4>And Select Your Ship</h4>
<img class="avatars" id="ship1" src="images/spaceship1.png">
<img class="avatars" id="ship2" src="images/spaceship2.png">
<img class="avatars" id="ship3" src="images/spaceship3.png">
<img class="avatars" id="ship4" src="images/spaceship4.png">
<button class="btn" id="submitPlayer">Submit</button>
</div>
and you may do the same with input :
.input-group,
input#word.text-center{
display: block;
margin: auto;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="input-group">
<input class="text-center" type="text" id="word">
</div>

How to add an image to a CSS popup box

<div class="showUserInfo noPrint" id="showUserInfo">
<div class="hidOverflow brClear fullWidth vertAlignT allAroundPad">
<div class="setFloatL hidOverflow vertAlignT" style="width: 55%;">Login User: </div>
<div class="setFloatL hidOverflow vertAlignT" style="width: 45%; color: #FFF;"><asp:Label ID="lblUserN" runat="server" ClientIDMode="Static" /></div>
</div>
<div class="hidOverflow brClear fullWidth vertAlignT allAroundPad">
<div class="setFloatL hidOverflow vertAlignT" style="width: 55%;">Workgroups: </div>
<div class="setFloatL hidOverflow vertAlignT" style="width: 45%; color: #FFF;">
<ul class="ulO" id="ulO" runat="server">
</ul>
</div>
</div>
<div class="hidOverflow brClear fullWidth vertAlignT allAroundPad" id="dvAdmin" runat="server">
<div class="setFloatL hidOverflow vertAlignT" style="width: 55%;">Admin Status: </div>
<div class="setFloatL hidOverflow vertAlignT" style="width: 45%; color: #FFF;"><asp:Image runat="server" ID="imgIsAdmin" ClientIDMode="Static" ImageUrl="~/theImages/admin_yes.png" CssClass="adminImg" /></div>
</div>
</div>
CSS:
.showUserInfo {
position: absolute;
background: #243942;
border: 4px solid #E55302;
overflow: hidden;
right: 45px;
min-height: 100px;
width: 350px;
top: 55px;
z-index: 200;
text-align: left;
padding: 10px;
color: #C0C0C0;
display: none;
}
Output:
I am looking to add an image to the left corner which goes outside of the box to look something like this:
I tried to change the HTML to the following but the image goes inside the box:
<div class="showUserInfo noPrint" id="showUserInfo">
<div class="hidOverflow brClear fullWidth vertAlignT allAroundPad">
<div class="setFloatL hidOverflow vertAlignT" style="width: 55%;">Login User: </div>
<div class="setFloatL hidOverflow vertAlignT" style="width: 45%; color: #FFF;"><asp:Label ID="lblUserN" runat="server" ClientIDMode="Static" /></div>
</div>
<div class="hidOverflow brClear fullWidth vertAlignT allAroundPad">
<div class="setFloatL hidOverflow vertAlignT" style="width: 55%;">Workgroups: </div>
<div class="setFloatL hidOverflow vertAlignT" style="width: 45%; color: #FFF;">
<ul class="ulO" id="ulO" runat="server">
</ul>
</div>
</div>
<div class="hidOverflow brClear fullWidth vertAlignT allAroundPad" id="dvAdmin" runat="server">
<div class="setFloatL hidOverflow vertAlignT" style="width: 55%;">Admin Status: </div>
<div class="setFloatL hidOverflow vertAlignT" style="width: 45%; color: #FFF;"><asp:Image runat="server" ID="imgIsAdmin" ClientIDMode="Static" ImageUrl="~/theImages/admin_yes.png" CssClass="adminImg" /></div>
</div>
<img src="../theImages/preloader_small.gif" style="position: absolute; left: -22px; top: -22px;" />
</div>
You do this using position values and negative positions.
See the jsfiddle
.box {
position: relative;
}
.image {
position: absolute;
top: -30px;
left: -30px;
}
And the important part of the example in the code above. The .box is position: relative; - the image (which could be any HTML element of course) is position: absolute; and the absolutely positioned element can then be positioned using top, left, right, bottom or z-index properties exactly where you want it. You might need z-index if something else was overlaying it to ensure it is on top.
Position absolute always positions the element at co-ordinates relative to the next item up the DOM tree where the position is set to relative or absolute, meaning that the position will remain set regardless of how the internal .box HTML changes. These co-ordinates default to 0x and 0y.

IE7 Div creating table

Only in IE does this not work, it displays the cells stacked vertically on top one another? Is there anyway to fix this so that IE7 will display it like a table?
<div class="table" style="width: 1100px; margin-top: 5px;";>
<div class="tr header">
<div class="td" style="width: 2%"></div>
<div class="td" style="width: 2%;"></div>
<div class="td" style="width: 14%;">Name</div>
<div class="td" style="width: 15%;">Company</div>
<div class="td" style="width: 9%;">Type</div>
<div class="td" style="width: 13%;">Phone</div>
<div class="td" style="width: 21%;">Email</div>
<div class="td" style="width: 17%;">City/State</div>
<div class="td" style="width: 8%;">Region</div>
</div>
<div class="tr">
<div class="td"><input type="image" name="Contacts1$rep$ctl01$imgdelbtn" id="Contacts1_rep_ctl01_imgdelbtn" src="images/del.png" style="border-width:0px;" /></div>
<div class="td"><img alt="" src="images/edit.png" style="width: 16px; height: 16px" /></div>
<div class="td">Bob Smith</div>
<div class="td"><a id="Contacts1_rep_ctl01_CompanyLnkBtn" href="javascript:__doPostBack('Contacts1$rep$ctl01$CompanyLnkBtn','')">Ops</a></div>
<div class="td">User</div>
<div class="td">555-555-5555</div>
<div class="td"><a href='mailto:ops#ops.com'>ops#ops.com</a></div>
<div class="td">Ops HI</div>
<div class="td">Midwest</div>
</div>
<div class="tr" style="background-color: #F0F0F0">
<div class="td"><input type="image" name="Contacts1$rep$ctl02$imgdelbtn" id="Contacts1_rep_ctl02_imgdelbtn" src="images/delete.png" style="border-width:0px;" /></div>
<div class="td"><img alt="" src="images/edit.png" style="width: 16px; height: 16px" /></div>
<div class="td">Bob Stevens</div>
<div class="td"><a id="Contacts1_rep_ctl02_CompanyLnkBtn" href="javascript:__doPostBack('Contacts1$rep$ctl02$CompanyLnkBtn','')">ABC CO</a></div>
<div class="td">User</div>
<div class="td">000.000.0000</div>
<div class="td"><a href='mailto:test#test.com'>test#test.com</a></div>
<div class="td">OHHNO CA</div>
<div class="td">Midwest</div>
</div>
</div>
CSS:
div.table
{
border: 1px solid #808080;
display: table;
}
div.tr
{
border: 1px solid #808080;
display: table-row;
}
div.td
{
border: 1px solid #808080;
display: table-cell;
height: 25px;
padding-left: 5px;
padding-right: 5px;
vertical-align: middle ;
}
div.header
{
background-color: #E0E0E0;
font-weight: bold;
}
Rows and columns of logically-associated data belong in a table. DIVs are the wrong tool for the job.
While we've all be told not to use TABLEs, that only applies to using them for layouts. A grid is not a layout, it is a table.
There really is no problem displaying tabular data in a table. That is the point of the table.
Don't feel that you need to display data in div tags.
Why don't you simply use table instead div?
If you look at this table you will see, that IE7 doesn not support "table". I suggest that you try to solve the problem with "float".
IE prior to IE8 doesn't support display: table*
Don't even try. It won't work.