I want to make a table which isn't editable under certain conditions, so I want to overlay it with a div.
Why is this not working?
CSS
<style type="text/css">
#div_tabel_basisgegevens {
background-color: red;
float:left;
position:relative;
left:0px;
top:0px;
z-index:120;
width:750;
height:100px;
}
#tabel_basisgegevens {
height:100px;
color:white;
position:relative;
left:0px;
top:0px;
z-index:2;
}
</style>
HTML
<div id="div_tabel_basisgegevens">
<table id="tabel_basisgegevens">
<tr>
<td>
<input type="Checkbox" id="geen_periodes" />
</td>
</tr>
</table>
</div>
Wrap the div and table with another div. Give the parent div position:relative;. Give the overlay div opacity:0;position:absolute;width:100%;height:100%;
<style type="text/css">
#div_tabel_basisgegevens{
background-color: red;
float:left;
position:absolute;
left:0px;
top:0px;
z-index:120;
width:100%;
height:100%;
opacity:0;
}
#tabel_basisgegevens{
height:100px;
color:white;
left:0px;
top:0px;
z-index:2;
background:red;
}
#wrapper {position:relative;}
</style>
<div id="wrapper">
<div id="div_tabel_basisgegevens"></div>
<table id="tabel_basisgegevens">
<tr><td><input type="Checkbox" id="geen_periodes"></td></tr>
</table>
</div>
http://jsfiddle.net/RZQwb/2/
And as Nerd-Herd mentioned, if all you want to do is make an input field non-editable, the correct method is to add the disabled attribute ( disabled="disabled" for XHTML)
Related
I want to align the date and Summer clearance inside of this table but I want to keep the table centered of the image horizontally. I am open for not using a table to achieve the same effect but I can;'t use Flex. It needs to be supported in most emails.
.outer {
position:relative;
background-color:red;
display:block;
width:650px;
background-image:url(https://blog.prezi.com/wp-content/uploads/2019/03/1_pzUhL5WpOeViwICDDgiLUA.jpeg)
}
.inner {
position:absolute;
width:100px;
height:50px;
background-color:pink;
display:block;
bottom:-25px;
right:50%;
transform: translateX(50%);
margin:auto;
}
.hidden{
visibility:hidden;
}
#img-text{
position:absolute;
bottom:40px;
margin:auto;
width:100%;
font-family:Arial, Helvetica, sans-serif;
color:#ffffff;
text-align:center;
}
<table>
<tr>
<td>
<div class="outer">
<img class="hidden" src="https://blog.prezi.com/wp-content/uploads/2019/03/1_pzUhL5WpOeViwICDDgiLUA.jpeg">
<table id="img-text" align="center">
<tr><td>8/30-9/1</td></tr>
<tr><td>SUMMMER CLEARANCE</td></tr>
<tr><td><h3>20% OFF</h3></td></tr>
</table>
<div class="inner">Hello</div>
</div>
</td>
</tr>
</table>
This is what Ive got to work with. Ive tried using margin:auto and text-align with wrappers but can't find a way to align it left in the middle of the image.
Hope this makes sense :)
#img-text tr td { text-align: left ; }
you can target table data inside it and set align as you wish
[i want to do like this]
[1]: https://i.stack.imgur.com/OOSKk.png
I have created a div(div B) in body that has 100% width and it has another div (div A) which has two components in it.the Div A is not able to get width of only two elements its getting 100% width.
This is my code
<div id="con"> <div id="srbt"> <input id="srch" type="text" placeholder="Paste Youtube link" name="search"> <button id="btn">Download</button></div> </div>
* {
box-sizing: border-box;
}
#con {
display:block;
background: #502c6c;
height:125px;
width:100%;
padding:30px;
}
#srbt {
width:100%;
background: #ffffff;
height:65px;
border-radius:5px;
position:relative;
}
#srch {
display:block;
width:100%;
border:none;
height:65px;
border-radius:5px;
padding:0 20% 0 5%;
line-height:65px;
color:#6c7592;
font-size:20px;
}
#btn {
background:#ff5916;
border:none;
border-radius:5px;
height:59px;
width:20%;
position:absolute;
top:3px;
right:3px;
z-index:10;
color:#ffffff;
font-size:24px;
}
<div id="con">
<div id="srbt">
<input id="srch" type="text" placeholder="Paste Youtube link" name="search">
<button id="btn">Start</button>
</div>
</div>
I have this problem, I can't seem to figure out how do I make this red DIV not past through the div on the right side, I want to make it stay between the right and the left div menu.
Website Screenshot
HTML Code:
<body>
<div class="navigationBar_default">
<div class="facetubeLogo_default"></div>
<div class="facetubeText_container_default"><center><strong class="facetubeText_default"></strong></center></div>
</div>
<div class="content_default">
<div class="leftMenu_onProfile">
<button class="leftMenu_buttonOnProfile"><img class="leftMenu_buttonImage" src="images/myProfileButton_onLeftMenu_onProfile.png" /><br>MY PROFILE</button>
<button class="leftMenu_buttonOnProfile"><img class="leftMenu_buttonImage" src="images/optionsButton_onLeftMenu_onProfile.png" /><br>GENERAL</button>
<button class="leftMenu_buttonOnProfile"><img class="leftMenu_buttonImage" src="images/generalButton_onLeftMenu_onProfile.png" /><br>OPTIONS</button>
<button class="leftMenu_buttonOnProfile"><img class="leftMenu_buttonImage" src="images/supportUsButton_onLeftMenu_onProfile.png" /><br>SUPPORT US</button>
<button class="leftMenu_buttonOnProfile"><img class="leftMenu_buttonImage" src="images/logOutButton_onLeftMenu_onProfile.png" /><br>LOG OUT</button>
</div>
<!-- there must be some stuff here, otherwise leftMenu_onProfile will glitch out. -->
<div class="contentCenter_onProfile">
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaaaaaaaaaaaaaaAAAAAAAAAAAAAAAAAA
</div>
<!-- there must be some stuff here, otherwise leftMenu_onProfile will glitch out. -->
<div class="rightMenu_onProfile">user1<br>user2<br>user3<br>user4<br>user5</div>
</div>
CSS Code:
.navigationBar_default {
background-color:#202020;
width:100%;
height:32px;
margin-left:-8px;
margin-right:-8px;
border:0;
top:0;
position:fixed;
}
.facetubeLogo_default {
background-image:url("../images/facetube_icon_30x30_png.png");
width:30px;
height:30px;
margin-top:1px;
margin-left:1px;
float:left;
}
.facetubeText_container_default {
margin-top:6px;
}
.content_default {
width:100%;
height:100%;
margin-top:32px;
margin-left:-8px;
margin-right:-8px;
margin-bottom:-8px;
}
.leftMenu_onProfile {
background-color:#0d0d0d;
margin-top:0px;
margin-left:-8px;
width:240px;
float:left;
}
.leftMenu_buttonOnProfile {
background-color:#0d0d0d;
border:0;
border-bottom:1px solid #ffffff;
width:240px;
height:48px;
color:#ffffff;
}
.leftMenu_buttonImage {
float:left;
margin-top:-2px;
margin-right:-6px;
}
.contentCenter_onProfile {
background-color:red;
padding:2px; /* padding is originally removed */
margin:0px;
top:0px;
}
.rightMenu_onProfile {
background-color:#0d0d0d;
margin-top:-20px;
margin-right:-16px;
width:300px;
color:#ffffff;
float:right;
}
I have feeling it has to do something with content_default and the width:100% but I don't know. I tried everything and I couldn't figure it out.
:/
Try this:
.contentCenter_onProfile {
background-color:red;
padding:2px; /* padding is originally removed */
margin:0 300px;
top:0px;
width: 50%; /* SET THIS */
white-space: pre-wrap;
word-break: break-all;
}
By setting the width, you can ensure the div does not overlap the right hand side div.
Setting float: left or float: right causes the elements to overlap.
Quick question:
I am trying to reengineer a mailchimp pop up. There is a form element that is centered on the document, I'd like to convert it to a div element (simply to replace "form" with "div"). Problem is when I do, it is no longer centered.
Clearly there are differences in the default css for each of these two elements, what are they?
It isn't "display:block"
Thanks
<style type="text/css">
#mc_embed_signup{position:absolute; top:0; left:0; width:100%; height:100%; background-color:rgba(0,0,0,.8); z-index:10000; }
#mc_embed_signup form{position:fixed; top:10%; left:50%; width:50%; margin-left:-17%; font:normal 100% Helvetica,Arial,sans-serif; font-size:14px; border-radius:4px; border:none; padding:0; background-color:#fff; color:#000; text-align:left; overflow-y:auto; overflow-x:hidden; }
#mc_embed_signup a.mc_embed_close{ cursor:pointer; }
#mc-embedded-subscribe .button{ margin:0; padding:0; }
</style>
<script type="text/javascript">
$(document).ready(function(){
$("#mc_embed_close").click(function(){
$("#mc_embed_signup").hide();
});
alert($("#mc-embedded-subscribe-form").css('display'));
});
</script>
<div id="mc_embed_signup">
<form id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate style="width:500px; height:500px; background-repeat:no-repeat; background-position:center;">
<div class="mc-field-group">
<div style="position:relative">
<a href="/support">
<img src="/images/pop-ups/summer-drive-button.png" style="position:absolute; top:350px; border:1px dotted #ccc" />
</a>
<img src="/images/pop-ups/summer-drive.jpg" />
</div>
</div>
<a id="mc_embed_close" class="mc_embed_close" style="position:absolute; top:5px; right:10px;">×</a>
<div class="clear"></div>
<div id="mce-responses" class="clear">
<div class="response" id="mce-error-response" style="position:absolute; top:0; left:0; display:none"></div>
<div class="response" id="mce-success-response" style="width:300px; position:absolute; background-color:#FFF; top:30px; left:75px; display:none"></div>
</div>
</form>
</div>
The default style for a form differs depending on the browser and the rendering mode, but it's just a block element with some margin or padding.
Your CSS specifies position:fixed for the form element, and places it in the center of the window. If you exchange the form element for a div, you have to change the CSS so that it applies to the div instead. You probably want to add a class to the div so that you can target it specifically.
the code below demonstrates what i am trying to do. why is my "blackOut" div appearing in front of my "theGoods" div? shouldn't the z-index properly handle this?
<html>
<head>
<style>
table.theGoods{
display:block;
z-index:20;
background-color:yellow;
font-family:arial;
font-size:18px;
width:300px;
height:300px;
margin-right:auto;
margin-left:auto;
margin-top:180px;
text-align:center;
}
div.blackOut{
position:absolute;
background-color:red;
width:100%;
height:100%;
padding:0px;
top:0px;
left:0px;
z-index:2;
}
div.behindIt{
z-index:1;
background-color:red;
}
#myinnercontainer { position:absolute; top:50%; height:10em; margin-top:-5em }
</style>
</head>
<body>
<table class="theGoods" id="theGoods">
<tr>
<th>
la la
</th>
</tr>
</table>
<div class="blackOut" id="blackOut" onClick="myHider(event)"></div>
</body>
<script>
function myHider(e){
document.getElementById("blackOut").style.display="none";
}
</script>
</html>
z-index:20; has no effect without either position:absolute or position:relative. (You want the latter.)
z-index only affects elements with a position property other than 'static'. If you add position:relative; to table.theGoods, you should be fine. In general, all elements involved in the stacking need to have position:relative or position:absolute.
You cant use z-index without using:
position:absolute;
or:
position:relative;
which is lacking from table.theGoods
You need to add "position: absolute;" to the style for table.theGoods.