Centering just the DIV instead of the sidebar too - css
I have a header, a sidebar, and a content div.
The Header is docked to the top and fixed there. The sidebar is fixed the to the left. Now I have 3/4 of the screen on the right free of space. I have a content div that I want to place there. It needs to be centered in that 3/4 space.
Here is my code for the sidebar and content div.
CSS:
html,body {
height:100%;
}
#sidebar {
float: left;
width: 300px;
background: #fff;
background: rgba(225,225,225,0.2);
height:100%;
}
#sidebarTop {
height:100%;
background-color: #eee;
padding:20px 50px;
border-bottom:0.15em solid rgb(229,229,229);
background: rgba(225,225,225,0.25);
box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0 1px rgba(255,255,255,0.3), inset 0 10px rgba(255,255,255,0.2), inset 0 10px 20px rgba(255,255,255,0.25), inset 0 -15px 30px rgba(0,0,0,0.3);
-o-box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0 1px rgba(255,255,255,0.3), inset 0 10px rgba(255,255,255,0.2), inset 0 10px 20px rgba(255,255,255,0.25), inset 0 -15px 30px rgba(0,0,0,0.3);
-webkit-box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0px 1px rgba(255,255,255,0.3), inset 0px 0px rgba(255,255,255,0.2), inset 0 10px 20px rgba(255,255,255,0.25), inset -10px 0px 0px rgba(0,0,0,0.3);
-moz-box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0 1px rgba(255,255,255,0.3), inset 0 10px rgba(255,255,255,0.2), inset 0 10px 20px rgba(255,255,255,0.25), inset 0 -15px 30px rgba(0,0,0,0.3);
}
#content {
margin: 0 auto;
display:block;
width:400px;
margin-top:100px;
height:900px;
background:#FFF;
-webkit-box-shadow: 0px 0px 30px rgba(255, 255, 255, 1);
-moz-box-shadow: 0px 0px 30px rgba(255, 255, 255, 1);
box-shadow: 0px 0px 30px rgba(255, 255, 255, 1);
}
Here is my HTML code for sidebar and content div.
<div id="sidebar">
<div id="sidebarTop">
....
</div>
</div>
<div id="content">
TEST
</div>
The problem comes here. What happens is that instead of ignoring the sidebar and pushing the content div to 100px down (margin-top:100px), it brings the side-bar down to the same level too.
My goal is to center that div both vertically and horizontally in that 3/4 of screen space left after the sidebar and the header fill the rest.
Any help is much appreciated!
Add float:left; to #content.
#content {
margin: 0 auto;
width:400px;
margin-top:100px;
height:900px;
background:#FFF;
-webkit-box-shadow: 0px 0px 30px rgba(255, 255, 255, 1);
-moz-box-shadow: 0px 0px 30px rgba(255, 255, 255, 1);
box-shadow: 0px 0px 30px rgba(255, 255, 255, 1);
}
should be:
#content
{
margin:100px auto 0;
width:400px;
height:900px;
background:#fff;
-webkit-box-shadow:0 0 30px #fff;
-moz-box-shadow:0 0 30px #fff;
box-shadow:0 0 30px #fff;
float:left;
}
Updated:
CSS
html,
body
{
height:100%;
}
#sidebar
{
position:fixed;
top:0;
left:0;
width:300px;
height:100%;
background-color:#758;
}
#content
{
margin-left:-50px;
position:absolute;
top:100px;
left:50%;
width:400px;
height:900px;
background:#758;
}
HTML
<div id="sidebar">
"fixed" sidebar
</div>
<div id="content">
"horizontally centered" content
</div>
DEMO
Update 2:
CSS
#wrapper
{
position:absolute;
top:100px;
left:300px;
right:0;
height:900px;
}
#content
{
margin:0 auto;
width:400px;
height:100%;
background:#758;
}
HTML
<div id="sidebar">
"fixed" sidebar
</div>
<div id="wrapper">
<div id="content">
"horizontally centered" content
</div>
</div>
DEMO 2
You could try in this way:
CSS:
html,body {
height:100%;
}
#sidebar {
border: 2px solid yellow; /*Added to show the box-model*/
float: left;
width: 25%;
background: #fff;
background: rgba(225,225,225,0.2);
height:100%;
}
#sidebarTop {
border: 2px solid black; /*Added to show the box-model*/
height:100%;
background-color: #eee;
padding:20px 50px;
border-bottom:0.15em solid rgb(229,229,229);
background: rgba(225,225,225,0.25);
box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0 1px rgba(255,255,255,0.3), inset 0 10px rgba(255,255,255,0.2), inset 0 10px 20px rgba(255,255,255,0.25), inset 0 -15px 30px rgba(0,0,0,0.3);
-o-box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0 1px rgba(255,255,255,0.3), inset 0 10px rgba(255,255,255,0.2), inset 0 10px 20px rgba(255,255,255,0.25), inset 0 -15px 30px rgba(0,0,0,0.3);
-webkit-box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0px 1px rgba(255,255,255,0.3), inset 0px 0px rgba(255,255,255,0.2), inset 0 10px 20px rgba(255,255,255,0.25), inset -10px 0px 0px rgba(0,0,0,0.3);
-moz-box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0 1px rgba(255,255,255,0.3), inset 0 10px rgba(255,255,255,0.2), inset 0 10px 20px rgba(255,255,255,0.25), inset 0 -15px 30px rgba(0,0,0,0.3);
}
#foo {
border: 2px solid pink; /*Added to show the box-model*/
margin-top: 100px;
margin-left: 27%;
width: 73%;
}
#content {
border: 2px solid green; /*Added to show the box-model*/
margin: 0 auto;
display:block;
width:400px;
/*margin-top:100px;*/ /*this can be deleted*/
height: 100%;
background:#FFF;
-webkit-box-shadow: 0px 0px 30px rgba(255, 255, 255, 1);
-moz-box-shadow: 0px 0px 30px rgba(255, 255, 255, 1);
box-shadow: 0px 0px 30px rgba(255, 255, 255, 1);
}
And HTML:
<div id="sidebar">
<div id="sidebarTop">
....
</div>
</div>
<div id="foo">
<div id="content">
TEST
</div>
</div>
#sidebarTop {
margin: 0 auto;
}
You can simply use "center" tag like this:
<div id="content">
<center>
TEST
</center>
</div>
Related
3D Painting frame effect using CSS
I am trying to replicate canvas frame effect on paintings on images using CSS. I can do shadows and rounded corners but I couldn't figure out how to do the 3D effect of "rounded/wrapping sides". My actual is left image while I am trying to replicate the effect of the right one. Please ignore the background of the expected image. Any help? Thanks. .image{ display:flex; justify-content:space-evenly; } #actual { border-radius: 4px; box-shadow: 20px 4px 10px rgba(0,0,0,0.35), 40px 8px 10px rgba(0,0,0,0.15); } <div class="image"> <img id="actual" src="http://lorempixel.com/output/cats-q-c-640-480-10.jpg"> <img id="expected" src="https://i.imgur.com/XD8Vdvv.jpg"> </div>
You can approximate it using inset shadow: .image{ display:inline-block; border-radius: 4px; box-shadow: -2px -2px 1px rgba(0,0,0,0.5) inset, 20px 4px 10px rgba(0,0,0,0.35), 40px 8px 10px rgba(0,0,0,0.15); width:320px; height:240px; margin:10px; background:url(http://lorempixel.com/output/cats-q-c-640-480-10.jpg) center/cover; } <div class="image"> </div>
Just want to get creative with box-shadow layering... Cheers; figure { display: block; margin: 1rem auto; height: 10rem; width: 10rem; border: gray 1px solid; border-radius: 3px; background: lightgray url('https://i.stack.imgur.com/BVW9D.jpg') no-repeat center center; background-size: cover; box-shadow: 2px 2px 0 gray, 3px 3px 4px rgba(0,0,0,.9), 6px 6px 12px 4px rgba(0,0,0,.25), 0 0 14px 4px rgba(0,0,0,.15); } <figure></figure>
webkit-box-shadow:inset not working on Chrome Version 48.0.2564.109
I have a problem with webkit-boxshadow it doesn't work in latest chrome browser this is the code can any give solution please. it works good in firefox. option:checked { box-shadow: 0 0 10px 100px #2eb135 inset; -webkit-box-shadow: 0 5pc -5px 100px #2eb135 inset;} option:hover{-webkit-box-shadow: 0px 0px 8px 2px #CCCCCC inset;}
According to CanIUse the box-shadow property does not need a prefix anymore. So you would be fine with just using the following styles: option:checked { box-shadow: inset 0 0 10px 100px #2eb135; } option:hover { box-shadow: inset 0 0 8px 2px #CCCCCC; }
It does work. You might want to reconsider your parameters. Don't you think 100px spread is a bit much? Try decreasing that value! Sample: .c-test { width: 10vw; height: 10vw; margin: auto; margin-bottom: 25px; padding: 10px; background-color: #f00; } .c-test__ok { box-shadow: 0 0 10px 10px #2eb135 inset; -webkit-box-shadow: 0 5pc -5px 10px #2eb135 inset; } .c-test__your-code { box-shadow: 0 0 10px 100px #2eb135 inset; -webkit-box-shadow: 0 5pc -5px 100px #2eb135 inset; } <div class="c-test c-test__ok"> DIV with OKish shadow </div> <div class="c-test c-test__your-code"> Your CSS </div>
Effect of bottom view for a text using CSS
Whether it is possible tilt, rotate, shrink 3d text? I want to create an effect of bottom view on my text (or if text lies on a table) using only CSS. Is it possible? I do not mean the animation, only static effect. I can do it in the 3dsMAX or PhotoShop, but I want to know how it can be implemented in CSS. I have: Fiddle I want: I got a little bit this effect (due to the large shadow). But I want to make it more clear and explicit. Further increase in the shade does not enhance the effect. I need to tilt and compress vertically my text. What styles can help me in this? I would be grateful for any ideas! My shadow styles: text-shadow: 0px 0px 0 rgb(221,120,128), -1px 1px 0 rgb(215,114,122), -2px 2px 0 rgb(209,108,116), -3px 3px 0 rgb(203,102,110), -4px 4px 0 rgb(197,96,104), -5px 5px 0 rgb(191,90,98), -6px 6px 0 rgb(185,84,92), -7px 7px 0 rgb(178,77,85), -8px 8px 0 rgb(172,71,79), -9px 9px 0 rgb(166,65,73), -10px 10px 0 rgb(160,59,67), -11px 11px 0 rgb(154,53,61), -12px 12px 0 rgb(148,47,55), -13px 13px 0 rgb(142,41,49), -14px 14px 0 rgb(136,35,43), -15px 15px 0 rgb(130,29,37), -16px 16px 15px rgba(0,0,0,0.6), -16px 16px 1px rgba(0,0,0,0.5), 0px 0px 15px rgba(0,0,0,.2); }
that is not easy i think you will need js for that,unfortunately css text-shadow property is only 2 dimensional. Here is a quick example, use your keyboard to controll the angle 0- REAL 3D USING ONLY CSS cross browser compatibility solution(prefixfree) For Cross-browser gradients (NO -webkit-,-moz-,-ms-) save your time using LeaVerou/prefixfree you can find a CDN Version here 3D DEMO with prefixfree & CSS only figure { transform-origin:center center; transform-style:preserve-3d; transform: rotate3d(-1,0,0,-72deg); } 1- REAL 3D USING JQUERY cross browser compatibility solution(prefixfree) 3D DEMO with Jquery MARKUP <figure></figure> JS var shadowLength = 40; for(var i = 0;i < shadowLength; i++){ var layer = $("<h1>3D TEXT</h1>").css("transform", "translateZ(-"+i+"px)"); $("figure").append(layer); } CSS * { box-sizing:border-box; } :root{ background-color: #00dbba; overflow:hidden; text-align:center; } figure { transform-origin:center center; transform-style:preserve-3d; transform: rotate3d(-1,0,0,-72deg); } h1:first-child{ color:white; } h1 { display:block; width:100%; padding:40px; line-height:1.5; font:900 8em 'Concert One', sans-serif; text-transform:uppercase; position:absolute; color:#51B3A3; } you can now choose the position by changing the value of rotateZ(Value deg) rotateX(Value deg) rotateY(Value deg) to get the perfect position. figure { transform-origin:center center; transform-style:preserve-3d; transform: rotateZ(0deg) rotateX(70deg) rotateY(-12deg); } deep understanding css3D Read how Nesting 3D Transformed Elements Works and don't miss [CSSconf.eu 2013] Ana-Maria Tudor: Maths-powered transforms for creating 3D shapes if you need more, read 1- css-3d-animation-how 2- Ana-Maria Tudor on stackoverflow 2- REAL 3D 3D DEMO with animation figure#figure3d { -webkit-transform: rotateX(54deg) scale(1) skew(10deg) translate3d(0px, 0px, 0px); -webkit-transform-origin:center center; -webkit-transform-style:preserve-3d; } you can remove the span if you don't like the animation at the beginning span{ display:none;/*comment me to remove the animation*/ } 3- IN GENERAL 3D DEMO with animation or change the angle like this -webkit-transform:rotate3d(-1,1,0,40deg); 3D DEMO without animation #figure3d span { color:silver; -webkit-text-shadow: 0px 1px 0px #c0c0c0, 0px 2px 0px #b0b0b0, 0px 3px 0px #a0a0a0, 0px 4px 0px #909090, 0px 5px 10px rgba(0, 0, 0, 0.6); -moz-text-shadow: 0px 1px 0px #c0c0c0, 0px 2px 0px #b0b0b0, 0px 3px 0px #a0a0a0, 0px 4px 0px #909090, 0px 5px 10px rgba(0, 0, 0, 0.6); -ms-text-shadow: 0px 1px 0px #c0c0c0, 0px 2px 0px #b0b0b0, 0px 3px 0px #a0a0a0, 0px 4px 0px #909090, 0px 5px 10px rgba(0, 0, 0, 0.6); text-shadow: 0px 1px 0px #c0c0c0, 0px 2px 0px #b0b0b0, 0px 3px 0px #a0a0a0, 0px 4px 0px #909090, 0px 5px 10px rgba(0, 0, 0, 0.6); } * { -webkit-box-sizing:border-box; } figure#figure3d { -webkit-transform: rotate(0deg) scale(1) skew(0deg) translate3d(0px, 0px, 0px); -webkit-transform-origin:center center; -webkit-transform-style:preserve-3d; } 4- USING ONLY CSS the max you can do using text-shadow only ist something like this #figure3d { -webkit-transform: rotateX(65deg) scale(1) skew(10deg) translate3d(0px, 0px, 0px); -webkit-transform-origin: center center; -webkit-transform-style: preserve-3d; font-size:3.6em; letter-spacing:10px; font-family: 'Alfa Slab One', cursive; font-weight:900; color:white; text-shadow: -1px 1px 0 #51B3A3, -2px 2px 0 #51B3A3, -2px 3px 0 #51B3A3, -2px 5px 0 #51B3A3, -2px 7px 0 #51B3A3, -2px 8px 0 #51B3A3, -2px 10px 0 #51B3A3, -2px 11px 0 #51B3A3, -3px 13px 0 #51B3A3, -3px 14px 0 #51B3A3, -3px 16px 0 #51B3A3, -3px 17px 0 #51B3A3, -4px 19px 0 #51B3A3, -4px 20px 0 #51B3A3, -4px 22px 0 #51B3A3, -4px 23px 0 #51B3A3, -4px 25px 0 #51B3A3, -4px 26px 0 #51B3A3, -5px 28px 0 #51B3A3, -5px 29px 0 #51B3A3; } 3D DEMO with text-shadow only you can then ajust it as you like!
I think this is what you're referring to (Fiddle). The transform selector is going to be your friend in this situation, i.e. transform: rotate(6.5deg) rotateX(188deg) skewX(-25deg). HTML: <div id="wrapper" contenteditable="true" spellcheck="false"> <p>Where</p> <p>are the</p> <p>trees</p> </div> CSS: #import url(http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz:bold); /* Global ------------------------------------------------------ */ html { height: 100%; font: 62.5%/1 "Lucida Sans Unicode","Lucida Grande",Verdana,Arial,Helvetica,sans-serif; background: url(http://s.cdpn.io/79/glow.png) no-repeat center center, url(http://s.cdpn.io/79/tilt-shift.jpg) no-repeat center center; background-size: auto, cover; } body { display: flex; justify-content: center; align-items: center; margin: 0; width: 100%; height: 100%; text-align: center; background-color: hsla(30,20%,95%,.9); } /* Wrapper ------------------------------------------------------ */ #wrapper { position: relative; text-align: center; font-weight: bold; font-family: "Yanone Kaffeesatz", "Lucida Grande", Lucida, Verdana, sans-serif; margin: 0 auto; width: 600px; padding: 7em 0; background: url(http://s.cdpn.io/79/tilt-shift.jpg) no-repeat center center; border-radius: 4px; box-shadow: inset 0 -1px 0 hsla(0,0%,0%,.2), 0 21px 8px -12px rgba(0,0,0,.2); perspective: 350; } #wrapper:focus { outline: none; } #wrapper p { font-size: 10em; margin: 0; color: #fff; text-transform: uppercase; letter-spacing: 0.03em; text-shadow: rgba(0,0,0,0.1) 0 20px 80px; -webkit-transition: -webkit-transform .1s ease-in; /* only WebKit because of performance */ } /* Hover ------------------------------------------------------ */ #wrapper:hover p { color: hsla(0,0%,0%,0); transform: rotate(6.5deg) rotateX(28deg) skewX(-4deg); -webkit-transition: -webkit-transform .1s ease-out; /* only WebKit because of performance */ } #wrapper:hover p:nth-child(1) { font-size: 9em; text-shadow: #fff 0 0 10px, #fff 0 4px 3px, #ddd 0 9px 3px, #ccc 0 12px 1px, rgba(0,0,0,0.2) 0 14px 5px, rgba(0,0,0,0.1) 0 20px 10px, rgba(0,0,100,0.2) 0 15px 80px; text-indent: 0.3em; } #wrapper:hover p:nth-child(2) { font-size: 10em; text-shadow: #fff 0 0 1px, #eee 0 4px 3px, #ddd 0 9px 3px, #ccc 0 12px 1px, rgba(0,0,0,0.2) 0 14px 3px, rgba(0,0,0,0.1) 0 20px 10px, rgba(0,0,100,0.2) 0 15px 80px; } #wrapper:hover p:nth-child(3) { font-size: 11em; text-shadow: #fff 0 0 2px, #fff 0 4px 5px, #ddd 0 9px 5px, #ccc 0 12px 10px, rgba(0,0,0,0.2) 0 14px 5px, rgba(0,0,0,0.1) 0 20px 10px, rgba(0,0,100,0.2) 0 15px 80px; } /* Middle ------------------------------------------------------ */ #wrapper p:nth-child(2):hover { text-shadow: #fff 0 -5px 1px, #eee 0 -1px 3px, #ddd 0 4px 3px, #ccc 0 7px 1px, rgba(0,0,0,0.2) 0 15px 5px, rgba(0,0,0,0.1) 0 20px 10px, rgba(0,0,0,0.2) 0 15px 80px; } #wrapper p:nth-child(2):active { text-shadow: rgba(0,0,0,0.2) 0 14px 5px, rgba(0,0,0,0.1) 0 20px 10px, rgba(0,0,0,0.2) 0 15px 80px; } #wrapper p::selection { background-color: red; }
You can get an aproximate result setting a rotation with perspective: display: inline-block; -webkit-transform: perspective(200px) rotateX(20deg); -webkit-transform-origin: 30% bottom; transform: perspective(60px) rotateX(23deg); transform-origin: 30% bottom; fiddle I set the display to inline-block so that the perspective is centered, otherwise it is skewed.
Bootstrap Image Circle Inner Shadow
How can I add an inner shadow to a bootstrap "image-circle"? jsfiddle This doesn't work.. .box-shad { box-shadow: 0 10px 20px #777 inset, 0 0 200px #000 inset, 0 0 150px #000 inset, 0 0 100px #000 inset; } <img class="img-circle box-shad" alt="" src="http://placehold.it/140x140"><img class="img-circle box-shad" alt="" src="http://placehold.it/140x140"> Thanks for any ideas. SOLUTION: Put the box shadow on a circular div with background image set to the image, rather than using an image.
You can try something like this: .box-shad { -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); } Demo: http://jsfiddle.net/52VtD/1926/ UPDATE I don't think it's possibile to set an inner shadow because it's an image; you can draw the circle too instead of use an image, so you'll can set the inner shadow. Code: .box-shad { -webkit-box-shadow: inset 0 0 4px #000; -moz-box-shadow: inset 0 0 4px #000; box-shadow: inset 0 0 4px #000; } .circle { width: 140px; height: 140px; display: inline-block; border-radius: 50%; background-color: #aaa; } Demo: http://jsfiddle.net/52VtD/1943/
This works to me. Please try it. .inner-shadow { box-shadow: inset 3px 3px 4px black; border-radius: 50%; } img { width: 100%; border-radius: 50%; position: relative; z-index: -10; } <div class="inner-shadow"> <img src="http://placehold.it/300x300" alt=""> </div>
Closest I get is this: http://jsfiddle.net/52VtD/1941/ <div class="border"> <a class="shadow img-circle"><img class="img-circle" src="http://placehold.it/140x140" /></a> CSS: .border { padding:10px; width:160px; } .shadow { display:block; position:relative; } .shadow img { display:block; } .shadow::before { display:block; content:''; position:absolute; width:100%; height:100%; -moz-box-shadow:inset 0px 0px 5px 2px rgba(0,0,0,0.2); -webkit-box-shadow:inset 0px 0px 5px 2px rgba(0,0,0,0.2); box-shadow:inset 0px 0px 5px 2px rgba(0,0,0,0.2); } this article may help http://designbystevie.com/2011/03/applying-css3-inset-box-shadows-to-images/
Wrapper does not expand until all data is loaded
On this image I labeled in red #container1 and its child #container2. #container2 has three column divs labeled in blue. I took this snapshot in the moment both containers were not expanded because of delayed load of external apps (addThis, Facebook, Adsense). After that both containers expand as expected. Anyway, I always see pictures (col2) and col1 displaying before #container2 is expanded. (fraction of a second delay but it exists) #container1{ text-align:center; width:926px; padding:15px; margin-left:12px; margin-bottom:10px; border:thin solid #999; -moz-border-radius:20px; -webkit-border-radius:20px; border-radius:20px; box-shadow: inset 0 0 15px #CCC; -moz-box-shadow: inset 0 0 15px #CCC; -webkit-box-shadow: inset 0 0 15px #CCC; min-heigt:950px } #container2 { width: 980px; text-align:left; /* reset text alignment */ margin:0 auto; position:relative; background-color:white; border: thin solid #999;/*#69c7e8;*/ border-top:none; box-shadow: 0px 5px 8px #CCC, -5px 5px 8px #CCC, 5px 5px 8px #CCC; -moz-box-shadow: 0px 5px 8px #CCC, -5px 5px 8px #CCC, 5px 5px 8px #CCC; -webkit-box-shadow: 0px 5px 8px #CCC, -5px 5px 8px #CCC, 5px 5px 8px #CCC; min-height:1000px; } #col_1{ float:left; width:200px; margin-left:0; text-align:left; } #col_2{ float:left; width:566px; text-align:left; } #col_3{ float:right; width:160px; margin-right:0; text-align:left; } As you can see in the picture #container1 expands immediately to its min-height value while #container2 does not. Anyway I don't like this patch using min-height. Is it possible to expand both containers at the same time contents are displayed?