MS Edge: overflow: hidden not working on box-shadow - html

I have applied a large box-shadow to a position: absolute <div>. Its parent <div> has overflow: hidden set which (from my understanding) should hide any overflowing box-shadow – and this works just fine on Chrome but for some reason not on MS Edge.
See the example here:
.outerbox {
width: 600px;
height: 600px;
background-color: red;
}
.innerbox {
width: 300px;
height: 300px;
margin-top: 150px;
margin-left: 150px;
display: table;
background-color: #fff;
position: fixed;
overflow: hidden;
}
.shadowbox {
position: absolute;
left: 50px;
width: 200px;
top: 50px;
height: 200px;
box-shadow: 0px 0px 0px 100px rgba(0, 0, 0, 0.85);
}
<div class="outerbox">
<div class="innerbox">
<div class="shadowbox">
</div>
</div>
</div>
https://jsfiddle.net/8u43mztw/
When viewed on Chrome it appears as one would expect like this:
But when viewed on MS Edge it appears as follows:
For some reason on Edge, setting overflow: hidden on the box parent to the box on which the box-shadow has been applied has no effect. Chrome has no trouble hiding the overflowing box-shadow. Am I doing something wrong here, or is there a workaround?

In Firefox also. Try to remove display: table; from .innerbox: in Firefox works fine.
.outerbox {
width: 600px;
height: 600px;
background-color: red;
}
.innerbox {
width: 300px;
height: 300px;
margin-top: 150px;
margin-left: 150px;
background-color: #fff;
position: fixed;
overflow: hidden;
}
.shadowbox {
position: absolute;
left: 50px;
width: 200px;
top: 50px;
height: 200px;
box-shadow: 0px 0px 0px 100px rgba(0, 0, 0, 0.85);
}
<div class="outerbox">
<div class="innerbox">
<div class="shadowbox">
</div>
</div>
</div>

Related

Fixed div inherit width of relative div

I've got a relative div with a width of 40%. After that there is a fixed div that needs to inherit this width.
So I set my html document to this:
<div class="sidebar"></div>
<div class="maincontent">
<div class="fixed--wrapper">
<div class="fixed--header">
</div>
</div>
</div>
And my css:
.sidebar {
width: 20%;
height: 100vh;
overflow: hidden;
position: fixed;
background-color: #000;
color: #fff;
float: left;
}
.maincontent {
float: right;
position: relative;
width: 80%;
background-color: #D00;
height: 300px;
}
.fixed--wrapper {
width: 40%;
position: relative;
float: left;
border-right: 1px solid rgba(0, 0, 0, 0.2);
height: 100%;
overflow-y: scroll;
background-color: #E00;
}
.fixed--header {
height: 60px;
width: inherit;
position: fixed;
z-index: 2;
background-color: #fff;
}
Now the problem arises that my fixed--header is like 8% bigger than the fixed--wrapper. To illustrate this view the following fiddle: https://jsfiddle.net/zj0Lpu0q/1/
I want my fixed--header to be 40% as well.
Sidenote: I know there are quiet the number of questions about this, but I couldn't find one that has a relative div with widths in percentages defined. Therefore I created this new question. If you could link me to another answer I'm happy as well.
Try replacing your css to this
.fixed--wrapper {
width: 40%;
position: relative;
float: left;
border-right: 1px solid rgba(0, 0, 0, 0.2);
height: 100%;
overflow-y: scroll;
background-color: #E00;}
.fixed--header {
height: 60px;
position:absolute;
width:100%;
z-index: 2;
background-color: #fff;}

CSS child element producing a margin the full width of parent

building an overlay containing a stylised container for some text, however this container seems to be producing a margin which when combined with the elements normal width takes up the entire parent element width. According to chrome dev tools its the .flipcontainerelement that is causing this.
It's really weird behaviour and I can't figure out why its behaving in this way.
If I wanted to place content to the right of the container for example, I would not be able to because of this margin being produced.
.flipcontainer {
height: 230px;
width: 150px;
}
.flipcalender {
border: 1px solid #dddddd;
border-radius: 25px;
margin: 0 auto;
margin-top: 0.2px;
background: linear-gradient(white, #f4f2f2);
}
.mmouter {
width: 100%;
height: 100%;
border: 1.5px solid #dddddd;
}
.mmmiddle {
width: 98%;
height: 98%;
}
.mminner {
width: 98%;
height: 98%;
background: linear-gradient(white, #f4f2f2);
position: relative;
}
.mmbreaker {
width: 99%;
background-color: white;
height: 2px;
position: absolute;
z-index: 1;
top: 115px;
}
#mmlightbox {
display: block;
width: 400px;
height: auto;
position: fixed;
top: 30%;
left: 40%;
z-index: 999;
background-color: white;
padding: 10px 20px 10px 0px;
/* margin-right: 239px; */
margin-top: -100px;
margin-left: -150px;
border: solid 2px #f21c0a;
}
<div id='mmlightbox'>
<div class='flipcontainer'>
<div class='flipcalender mmouter'>
<div class='flipcalender mmmiddle'>
<div class='flipcalender mminner'>
<p class='daysremaining'></p>
<p>days</p>
<div class='mmbreaker'></div>
</div>
</div>
</div>
</div>
</div>
Add float: right; to .flipcontainer css like so:
.flipcontainer {
height: 230px;
width:150px;
float: right;
}
Here is the JSFiddle demo
The margin you saw was because you specified the width to '150px'.
Adding float: left removes this and you can add content next to it
.flipcontainer {
height: 230px;
width:150px;
float: left;
}
See Fiddle http://jsfiddle.net/epe3bfdw/

How to insert a shadow below the slider

I have the following slider in my asp.net page:
<div class="sliderContent">
<div id="sliderFrame">
<div id="slideIT" class="sliderHolderMain">
<div u="slides" class="sliderHolder">
<div>
<img u="image" src="theImages/slider/1.jpg" />
<div u="caption" t="CLIP|L" class="sliderCapMain">
<div class="sliderCapBG"></div>
<div class="sliderCapText">
<span class="sliderCapTextHdr">Healthy Cooking</span>
<br />
<span class="sliderCapTextFtr">Discover simple solutions to cook delicious and healthy meals for you and your family. Cooking tips, how-to guides and more!</span>
</div>
</div>
</div>
<div>
<img u="image" src="theImages/slider/2.jpg" />
<div u="caption" t="CLIP|L" class="sliderCapMain">
<div class="sliderCapBG"></div>
<div class="sliderCapText">
<span class="sliderCapTextHdr">Healthy Cooking</span>
<br />
<span class="sliderCapTextFtr">Discover simple solutions to cook delicious and healthy meals for you and your family. Cooking tips, how-to guides and more!</span>
</div>
</div>
</div>
</div>
</div>
<div style="width: 1100px; min-width: 1000px; height: 10px; background: url(theImages/dropShadow.png) repeat-x; position: relative; margin: 0 auto; bottom: 0;"></div>
</div>
</div>
CSS:
.sliderContent
{
width: 100%;
overflow: hidden;
margin: 0 auto;
text-align: center;
}
#sliderFrame
{
position: relative;
width: 100%;
margin: 0 auto; /*center-aligned*/
}
.sliderHolderMain
{
position: relative;
margin: 0px;
padding: 0px;
float: left;
top: 0px;
left: 0px;
width: 1100px;
height: 337px;
overflow: hidden;
}
.sliderHolder
{
cursor: move;
position: absolute;
left: 0px;
top: 0px;
width: 1100px;
height: 337px;
overflow: hidden;
}
.sliderCapMain
{
position: absolute;
top: 0px;
left: 0px;
width: 300px;
height: 337px;
text-align: center;
}
.sliderCapBG
{
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
background: rgba(255, 255, 255, 0.75);
filter: alpha(opacity=75);
}
.sliderCapText
{
position: absolute;
top: 5%;
left: 5%;
color: #000;
text-align: left;
}
.sliderCapTextHdr
{
color: #0074C9;
font-weight: normal;
}
.sliderCapTextFtr
{
color: #000;
font-size: small;
}
Attached image of what it looks like:
As you can see the shadow is at the top of the slider pointed by the red arrow.
How can I modify the CSS so it appears below the slider, giving it a 3D view
2 ways: in your HTML, you have an inline style (eeeeew!!!) as follows:
<div style="width: 1100px; min-width: 1000px; height: 10px; background: url(theImages/dropShadow.png) repeat-x; position: relative; margin: 0 auto; bottom: 0;"></div>
and at the same time, your slider has a fixed height, so it's really easy to know the size.
So you can do the following:
1) remove the inline styles. Really.
2) add a class to that div, let's say .shadow
3) add the following styles to your CSS style sheet:
.shadow{
width: 1100px;
min-width: 1000px;
height: 10px;
position: relative;
margin: 0px auto;
top: 327px; //it was originally 327 but corrected to 337
background: url('theImages/dropShadow.png') repeat-x scroll 0% 0% transparent;
}
3.a) now you can use what you have now, which is a .png image (but you'll have to flip it vertically)
3.b) or you can use box-shadow property:
.shadow{
width: 1100px;
min-width: 1000px;
height: 10px;
position: relative;
margin: 0px auto;
top: 327px; //it was originally 327 but corrected to 337
box-shadow: -20px -5px 6px rgba(0, 0, 0, 0.75) inset;
}
EDIT: I see you edited my answer and somehow the edit was approved, but the edit is incorrect, so I'll explain it so you also understand how it works: the top position is the height of the container element (337px) minus the height of the div with the shadow (10px), so position is 327px. If you want a shadow div with (say) 50px height, then position would be 287px (337-50) and so on. Explaining this because this answer may be of help for you but also for other people as well, and having this corrected would end with the whole solution not working (literally disappearing off sight)

CSS for an image sitting inside a div within a lightbox (Many layers)

I am having some issues getting my head around the dimensions of an image sitting within a div that is inside a lightbox. So to break it down:
1 light box
2 columns in the lightbox named lhc and rhc
The image sits in lhc but I no matter if I use % or px its distorts the thumb.
The image needs to not distort regardless of original size but needs to scale down and sit dead centre of the lhc div.
See code and where am I going wrong:
.imagebox_container {
height: 600px;
width: 800px;
}
.fancybox-prev {
width: 20%;
}
.fancybox-next {
width: 20%;
right: 400px;
}
.lhc {
width: 500px;
height: 100%;
position: relative;
float: left;
display: block;
background-color: #000;
}
.rhc {
width: 300px;
background-color: #FFF;
height: auto;
position: relative;
overflow-y: scroll;
}
.fancyimg{
height: 50%; width: 50%; display:block;
margin:auto; margin-top: 25%;}
Here is the html/php:
<div class="imagebox_container">
<div class="lhc"><img class="fancyimg" src="uploads/folio/<?php echo $imgdata['filename']; ?>" /></div>
<div class="rhc">
<div id="imagedetails">
<div id="imagedetails_useravatar"></div>
<div id="imagedetails_username"></div>
</div>
<hr />
<div id="likeboard"></div>
<div id="commentboard">
<?php /* Load comments */ ?>
<?php while($row = mysqli_fetch_assoc($result_comments)){ ?>
<div class="commentbox"><span class=""><span class="comment"><?php echo $row['comment']; ?></span></span></div>
<hr />
Hi I was playing around with max-heights/widths but am a little closer...
.fancyimg{
max-height: 50%; max-width: 50%; display:block;
margin:auto; margin-top: 25%;}
I figured out the issues, see my code. Works perfectly ok now.
.imagebox_container { height: 600px; width: 1000px; }
.fancybox-prev { width: 20%; }
.fancybox-next { width: 20%; right: 400px; }
.lhc { width: 700px;
height: 100%;
position: relative;
float: left;
display: block;
background-image: url('/graphics/ps_neutral.png');
clear: both;
text-align: center; }
.rhc { width: 300px;
height: 100%;
background-color: #FFF;
height: auto;
position: relative;
float: right;
overflow-y: scroll; }
.fancyimg { max-height: 80%;
max-width: 80%;
display:block;
position:absolute;
margin-top: 10%;
margin-left: 70px;
-moz-box-shadow: 0px 5px 10px 5px rgba(0, 0, 0, 0.7);
-webkit-box-shadow: 0px 5px 10px 5px rgba(0, 0, 0, 0.7);
box-shadow: 0px 5px 10px 5px rgba(0, 0, 0, 0.7); }

absolute center horizontal, negative margin, IE6

Using negative margin to put an element at center works fine in all modern browsers, who support it.
But in IE6, what can we do?
For example, this code fails in IE6:
HTML:
<div id="parent">
<div id="child"></div>
</div>
CSS:
#parent{
position: relative;
width: 500px;
height: 500px;
margin: 25px auto;
background: skyblue;
}
#child{
position: absolute;
width: 300px;
height: 100px;
left: 50%;
margin-left: -150px;
top: 25px;
background: orange;
}
See this fiddle.
This might not apply to your specific scenario but can you try using margins and padding rather than positioning?
#parent{
width: 500px;
height: 500px;
margin: 25px auto;
padding-top: 25px;
background: skyblue;
}
#child{
width: 300px;
height: 100px;
margin-left: auto;
margin-right: auto;
background: orange;
}