Box shadow inner covered by another div - html

I have a div that containing a inner box shadow, but these shadow is coverd by another div, i tried with postion:relative but nothing is changed.
Here is a example
CODE EXAMPLE
example-div{
background:#fff;
color:#000;
margin-top: 10px;
margin-bottom: 20px;
margin-left: 15px;
width:260px;
height:250px;
border-radius: 100%;
border:6px solid red;
position: relative;
-webkit-box-shadow: inset 7px 7px 5px -5px rgba(50, 50, 50, 0.75);
-moz-box-shadow: inset 7px 7px 5px -5px rgba(50, 50, 50, 0.75);
box-shadow: inset 7px 7px 5px -5px rgba(50, 50, 50, 0.75);
}
Thanks in advance !

2 things you need to do - change the z-index of your picture so that it is behind your circular div, and then change the background of your circular div so that it is transparent instead of white.
.example-div{
background: transparent; /*this way you can see behind the circle*/
color:#000;
margin-top: 10px;
margin-bottom: 20px;
margin-left: 15px;
width:260px;
height:250px;
border-radius: 100%;
border:6px solid red;
position: relative;
-webkit-box-shadow: inset 7px 7px 5px -5px rgba(50, 50, 50, 0.75);
-moz-box-shadow: inset 7px 7px 5px -5px rgba(50, 50, 50, 0.75);
box-shadow: inset 7px 7px 5px -5px rgba(50, 50, 50, 0.75);
}
.example-div img{
width:260px;
height:250px;
border-radius: 100%;
position: relative; /*needed for z-index*/
z-index: -1; /*positions behind the circular div, but you can still see because of transparent background*/
}
<div class="example-div">
<img src="http://cdn.wonderfulengineering.com/wp-content/uploads/2014/09/new-wallpaper-18.jpg"/>
</div>

Related

How to only get the 'box-shadow-right' that cuts off when you reach a border?

how to get a good shadow (AT THE border-right OF THE SMALL DIV) that is equal to the shadow of the large div but that does cut of as it reaches the border-bottom of the small div / the border-top of the large div.
NOTE: I CANNOT use Z-index, I have a website way more complicated. Also, Spread CANNOT be used here because that doesnt cut off when it reaches the border-bottom/border-top, it won't look 3d anymore.
the html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<div id="small"></div>
<div id="large"></div>
</body>
</html>
And here, the CSS:
#small {
border: 1px solid black;
width: 200px;
height: 50px;
}
#large {
width: 300px;
border: 1px solid black;
height: 100px;
-webkit-box-shadow: 7px 7px 5px 0px rgba(50, 50, 50, 0.75);
-moz-box-shadow: 7px 7px 5px 0px rgba(50, 50, 50, 0.75);
box-shadow: 7px 7px 5px 0px rgba(50, 50, 50, 0.75);
}
I also have a JS Bin: http://jsbin.com/vijujaweja/edit
-I know, the question is formatted a bit bad, but I hope you understand my question.-
Why not just add background color to the divs?
JS Bin Here
#small {
border: 1px solid black;
width: 200px;
height: 50px;
background-color:#fff;
}
#large {
width: 300px;
border: 1px solid black;
height: 100px;
background-color:#fff;
}
.dropshadow {
-webkit-box-shadow: 7px 7px 5px 0px rgba(50, 50, 50, 0.75);
-moz-box-shadow: 7px 7px 5px 0px rgba(50, 50, 50, 0.75);
box-shadow: 7px 7px 5px 0px rgba(50, 50, 50, 0.75);
}
Do you want it like this? http://jsbin.com/xohomaraqe/1/edit I have updated some code.
Updated
This should work then
#small{
-webkit-box-shadow: 9px 1px 3px -1px rgba(50, 50, 50, 0.75);
}

How to make box arrows using css3?

I'd like to make this arrows in my site:
How can I make this one using css3 having a transparent background?
Thanks
You could use a font for the arrows and then CSS for the circles.
See working fiddle with Font Awesome:
http://jsfiddle.net/t2UA5/1/
<div class="halfCircleLeft"><i class="fa fa-angle-left"></i></div>
<div class="halfCircleRight"><i class="fa fa-angle-right"></i></div>
CSS
.halfCircleRight{
height:90px;
width:45px;
border-radius: 0 90px 90px 0;
-moz-border-radius: 0 90px 90px 0;
-webkit-border-radius: 0 90px 90px 0;
background:transparent;
-webkit-box-shadow: 4px 0px 25px 0px rgba(50, 50, 50, 0.75);
-moz-box-shadow: 4px 0px 25px 0px rgba(50, 50, 50, 0.75);
box-shadow: 4px 0px 25px 0px rgba(50, 50, 50, 0.75);
position:relative;
z-index:50;
}
.halfCircleLeft{
height:90px;
width:45px;
border-radius: 90px 0 0 90px;
-moz-border-radius: 90px 0 0 90px;
-webkit-border-radius: 90px 0 0 90px;
background:transparent;
-webkit-box-shadow: -4px 0px 25px 0px rgba(50, 50, 50, 0.75);
-moz-box-shadow: -4px 0px 25px 0px rgba(50, 50, 50, 0.75);
box-shadow: -4px 0px 25px 0px rgba(50, 50, 50, 0.75);
position:relative;
z-index:50;
}
.fa.fa-angle-left {
color:#27367A;
font-size:30px;
position:relative;
z-index:150;
top:30px;
left:20px;
}
.fa.fa-angle-right {
color:#27367A;
font-size:30px;
position:relative;
z-index:150;
top:30px;
left:15px;
}
I think this code help you :
<div class="arrow-bg">
<div class="arrow">
</div>
</div>
.arrow-bg {
border-radius:30px;
box-shadow:-10px 0 8px #EDEDED;
padding:20px 15px;
width:30px;
}
.arrow {
width: 0;
height: 0;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-right:10px solid blue;
}
This is the simple arrow and now you can add shadows and so on...
<div id="some_div">some text</div>
<div id="arrow"></div>
#arrow {
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-right:10px solid white;
float: left;
height: 1px;
}

Div's misalign after child <p> inserted

I have 2 div's, one 50% width, the other 25%.
They're suppose to both sit centred horizontally on the one line.
I can get this working fine. But when I insert a paragraph they break.
Any idea why?
http://jsfiddle.net/3KuJa/
html:
<section>
<div class="twothird"> </div>
<div class="onethird"><p>test</p></div>
</section>
css:
.onethird {
width: 25%;
background: white;
min-height: 20em;
display: inline-block;
margin: 20em 3%;
-webkit-box-shadow: 2px 2px 6px 0px rgba(50, 50, 50, 0.75);
-moz-box-shadow: 2px 2px 6px 0px rgba(50, 50, 50, 0.75);
box-shadow: 2px 2px 6px 0px rgba(50, 50, 50, 0.75);
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
padding: 2em;
text-align:left;
}
.twothird {
width: 50%;
background: white;
min-height: 20em;
display: inline-block;
margin: 20em 3%;
-webkit-box-shadow: 2px 2px 6px 0px rgba(50, 50, 50, 0.75);
-moz-box-shadow: 2px 2px 6px 0px rgba(50, 50, 50, 0.75);
box-shadow: 2px 2px 6px 0px rgba(50, 50, 50, 0.75);
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
padding: 2em;
text-align:left;
}
Inline block elements align, by default to baseline
This should fix it if applied to both inline-block divs
CSS
display: inline-block;
vertical-align: top;
Adjusted JSfiddle Demo
You may have to widen the display window to check.
since you have box-shadow, i am proposing a solution supported by IE8+ :
use display :table /table-cell for section and div
section {
display:table; /* make parent table type */
width:60%; /* give width */
margin :0 auto; /* center your section */
border:1px solid green /* just for display */
}
.onethird {
width: 25%;
background: white;
min-height: 20em;
display:table-cell;
/* display: inline-block; changed this value */
margin: 20em 3%;
-webkit-box-shadow: 2px 2px 6px 0px rgba(50, 50, 50, 0.75);
-moz-box-shadow: 2px 2px 6px 0px rgba(50, 50, 50, 0.75);
box-shadow: 2px 2px 6px 0px rgba(50, 50, 50, 0.75);
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
padding: 2em;
text-align:left;
border:1px solid red;
}
.twothird {
width: 50%;
border:1px solid red;
background: white;
min-height: 20em;
display:table-cell;
/* display: inline-block; changed this value */
margin: 20em 3%;
-webkit-box-shadow: 2px 2px 6px 0px rgba(50, 50, 50, 0.75);
-moz-box-shadow: 2px 2px 6px 0px rgba(50, 50, 50, 0.75);
box-shadow: 2px 2px 6px 0px rgba(50, 50, 50, 0.75);
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
padding: 2em;
text-align:left;
}
Keep in mind : your fiddle doesn't have set width and height to html, body...always declare that, it avoids many messy problems later in DOM - rule of thumb :)
Working fiddle
The source of the problem is indeed the interaction of the baseline alignment between the p and the empty inline box to the left of it.
In addition to using vertical-align: top to fix the problem, you can also use overflow:auto applied to .onethird and .twothird, which triggers a new block formatting context which prevents the text lines from the two inline-block containers from interacting with each other.
See demo at: http://jsfiddle.net/audetwebdesign/6vnh3/

Boxes floated to the left get pushed over to the right when expanded with jQuery

The best way I can explain this is with a JSFiddle example: http://jsfiddle.net/8tXku/
I'm floating each .project div to the left and using some simple jQuery to make them expand to show a description when clicked, however if you click the first project it will push the third project to the right, because it's taking up too much space when expanded.
Is there a way to get the third project div to just gracefully move down the page with the expanded content rather than move over to the right?
This may be a dirty solution but its works perfectly.
Giving the .project-description a position:absolute; will allow it to .slideDown() without affecting the surrounding divs, yet some other tweaks had to be made.
I added position:relative; to .project so that each .project-description is contained within it.
Final CSS
.project {
width: 250px;
float: left;
border: 1px solid #dedede;
border-radius: 6px;
-webkit-box-shadow: 0px 0px 20px rgba(50, 50, 50, 0.4);
-moz-box-shadow: 0px 0px 20px rgba(50, 50, 50, 0.4);
box-shadow: 0px 0px 20px rgba(50, 50, 50, 0.4);
margin-right: 30px;
margin-bottom: 30px;
position:relative;
}
.project-description {
padding: 5px;
font-size: 12px;
display: none;
position:absolute;
background-color:white;
left:0;
right:0;
z-index:99;
}
Check this out : http://jsfiddle.net/AliBassam/N4U3R/
UPDATE
When .project-description contains a big text (obviously) it will be hidden under the bottom div, just add z-index:99; to .project-description
Check this out: http://jsfiddle.net/AliBassam/pMGDZ/
Replace .project-description current style with this
.project-description {
padding: 5px;
font-size: 12px;
display: none;
position: absolute;
-webkit-box-shadow: 0px 0px 20px rgba(50, 50, 50, 0.4);
-moz-box-shadow: 0px 0px 20px rgba(50, 50, 50, 0.4);
box-shadow: 0px 0px 20px rgba(50, 50, 50, 0.4);
width:325px;
border-radius: 0 0 6px 6px;
background: #FFFFFF;
z-index: 1;
}
DEMO: http://jsfiddle.net/enve/8tXku/4/

How to create shadow only left and right side, on a line?

i have a line of width: 15px; and height of 2px;
my question is, how to create the shadow only on right and left side?
This fiddle has examples showing shadows only on:
Top and bottom
Left and right
Top
With that you should be able to do any kind of shadow.
http://jsfiddle.net/rafaelchiti/5jdHW/
The code:
div {
margin-top: 20px;
margin-left: 20px;
width: 100px;
height: 100px;
}
.horizontal {
box-shadow: 0px 15px 10px -11px rgba(0, 0, 0, .1) inset,
0px -15px 10px -11px rgba(0, 0, 0, .1) inset;
}
.vertical {
box-shadow: 0px 15px 10px -11px rgba(0, 0, 0, .1) inset,
0px -15px 10px -11px rgba(0, 0, 0, .1) inset;
}
.one-side {
box-shadow: 0px 15px 10px -11px rgba(0, 0, 0, .1) inset;
}
Hope this help.
Try this (based on the link you gave in your comment above):
box-shadow: 2px 2px 5px 2px rgba(0, 0, 0, 1);
-webkit-box-shadow: 2px 2px 5px 2px rgba(0, 0, 0, 1);
You can tweak it to how you like it using the CSS3 Generator
CSS Box Shadow
Add the following class to apply shadow. Check this jsfiddle example
.shadow {
-moz-box-shadow: 3px 3px 10px 1px #000;
-webkit-box-shadow: 3px 3px 10px 1px #000;
box-shadow: 3px 3px 10px 1px #000;
}
The horizontal offset of the shadow, positive means the shadow will
be on the right of the box, a negative offset will put the shadow on
the left of the box.
The vertical offset of the shadow, a negative one means the
box-shadow will be above the box, a positive one means the shadow
will be below the box.
The blur radius (optional), if set to 0 the shadow will be sharp,
the higher the number, the more blurred it will be.
The spread radius (optional), positive values increase the size of
the shadow, negative values decrease the size. Default is 0 (the
shadow is same size as blur).
Color Hexadecimal color value.
.box {
height: 150px;
width: 300px;
margin: 20px;
border: 1px solid #ccc;
}
.top {
box-shadow: 0 -5px 5px -5px #333;
}
.right {
box-shadow: -5px 0 5px -5px #333;
}
.bottom {
box-shadow: 0 5px 5px -5px #333;
}
.left {
box-shadow: 5px 0 5px -5px #333;
}
.all {
box-shadow: 0 0 5px #333;
}
in the body put..
<div class="box top"></div>
<div class="box right"></div>
<div class="box bottom"></div>
<div class="box left"></div>
<div class="box all"></div>