I'm working on a menu list and I want to get rid of the shadow under the selected li, in this example the letter C.
This is my code so far.
html,
body {
background: #0769AD;
margin: 0 auto;
padding: 0;
}
div {
width: 400px;
margin: 0 auto;
padding: 0;
text-align: center;
}
div ul {
background: #fff;
width: 100%;
margin: 0;
padding: 0;
border-radius: 0px 0px 10px 10px;
box-shadow: rgba(255, 255, 255, 0.3) 0 1px 0, rgba(0, 0, 0, 0.3) 0 -1px 0;
box-shadow: 0 0 5px rgba(1, 1, 1, 0.7);
}
div ul li {
display: inline-block;
padding: 5px 20px;
}
.selected {
background: #0769AD;
box-shadow: inset 0px 8px 6px 0px rgba(0, 0, 0, 0.3);
}
<div>
<ul>
<li>A</li>
<li>B</li>
<li class='selected'>C</li>
<li>D</li>
</ul>
</div>
Update div ul { box-shadow: 0 -5px 5px rgba(1, 1, 1, 0.7);}
html,body{
background:#0769AD;
margin:0 auto;
padding:0;
}
div {
width:400px;
margin:0 auto;padding:0;
text-align:center;
}
div ul{
background:#fff;
width:100%;
margin:0;padding:0;
border-radius: 0px 0px 10px 10px;
box-shadow: 0 0 5px rgba(1, 1, 1, 0.7);
}
div ul li{
display:inline-block;
padding:5px 20px;
}
.selected{
background:#0769AD;
box-shadow: inset 0px 8px 6px 0px rgba(0,0,0,0.3);
position:relative;
}
.selected:after{
content:'';
display:block;
width:100%;
height:25px;
left:0;
top:0;
position:absolute;
box-shadow: 0 10px 0px #0769AD;
z-index:0;
}
<div>
<ul>
<li>A</li>
<li>B</li>
<li class='selected'>C</li>
<li>D</li>
</ul>
</div>
Related
I am having a couple issues with my Navigation bar. The first issue is I cannot figure out how to make the "active" size the same size as my hover. You will notice that the entire height of the navigation bar is highlighted on active.
Secondly, for some reason it isn't as apparent on codepen but in my actual situation my "main" div is on the same plane as the navbar resulting in the drop shadow to not be even and crisp. Hopefully you can see what I mean from the following image. I have tried playing with z-index with no luck.
https://codepen.io/kjpolker/pen/RMqNbL
Image is of the navigation bar itnersecting with the main div. The shadow almost "fades" out on the edge, how can I put the shadow in front?
HTML
<body>
<nav class="navigation-bar">
<img class="logo" src="images/logo.png" alt="Logo" width="100" height="100"/>
<ul>
<li class="active">TAB 1</li>
<li>TAB 2</li>
<li>TAB 3</li>
<li>TAB 4</li>
<li>TAB 5</li>
</ul>
</nav>
<main class="main">
<article class="summary">
<p></p>
</article>
<article id="image">
<img src="images/map.png" alt="" width="80%" height="80%" />
</article>
</main>
</body>
CSS
* {margin:0;padding:0;box-sizing:border-box}
html, body {text-align: center;}
body {
background-image: url(../images/BG.jpg); background-size: 100% 100%; background-position: top left; background-repeat: repeat;
justify-content: center; /* horizontal alignment / centering */
align-items: flex-start; /* prevents the #menu to fill the remaining height of the body */
}
.navigation-bar {
opacity: .9;
text-align: center;
width: 100%;
height: 120px;
background: #2A2A2A;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.7), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
/*
-webkit-box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
-moz-box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
*/
}
.logo {
float: left;
margin-left: 5%;
margin-right: 5%;
margin-top: 10px;
}
/* used with 100% wrapper */
ul {
display: inline;
display: flex; /* displays children inline */
width: 60%;
height: 120px;
list-style: none;
background: #2A2A2A;
}
li {
flex: 1; /* each takes as much width as it can, i.e. 25% */
}
li:last-child {
border-left: none;
border-right: none;
}
li a {
margin-top: 30px;
display: block;
text-align: center;
font: Verdana;
font-size: 16px;
color: #EAEAEA;
text-decoration: none;
padding: 20px 0; /* This adjusts the height of the tabs */
}
li a:hover {
background: linear-gradient(#404040, #3E3E3E);
}
.active {
background: linear-gradient(#2B2B2B, #232323);
}
p {
font-family: Verdana;
font-size: 16px;
}
/* Used in Home */
.main {
opacity: .75;
color: #EAE0D2;
margin: 0 auto;
width: 85%;
height: 1000px;
margin-top: 0;
background: linear-gradient(#2B2B2B, #232323);
box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
-webkit-box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
-moz-box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
If my understanding is correct, For your first issue changing
.active {
background: linear-gradient(#2B2B2B, #232323);
}
to
.active a{
background: linear-gradient(#2B2B2B, #232323);
}
will solve the issue.
I have that html
<div id="menu">
<a class="active"></a>
</div>
<div id="content"></div>
And that css
#menu {
position:absolute;
z-index:1;
}
#content {
position:absolute;
z-index:2;
text-shadow: -10px 3px 10px rgba(0,0,0,.23),0 3px 10px rgba(0,0,0,.16);
}
#menu a.active:after {
position:absolute;
z-index:3;
text-shadow: -10px 3px 10px rgba(0,0,0,.23),0 3px 10px rgba(0,0,0,.16);
}
I want a.active:after was above then #content so that the shadow does not dropped on the a.active:after. How i can do this?
Try like this: Demo
I removed box shadow from #content and added to #menu as inner shadow.
CSS:
#menu {
position:absolute;
z-index:7;
width:200px;
height:100%;
background:green;
box-shadow:inset -10px 3px 10px rgba(0, 0, 0, .23), inset 0 3px 10px rgba(0, 0, 0, .16);
overflow:hidden;
}
#menu a.active {
padding:5px;
background:#fff;
display:block;
margin-top:20px;
z-index:9;
}
#content {
position:absolute;
z-index:3;
width:100%;
height:100%;
background:yellow;
left:200px;
}
#menu a.active:after {
content:"";
position: absolute;
width: 24px;
height: 24px;
background: yellow;
transform: rotate(45deg);
/* Prefixes... */
top: 21px;
right: -11px;
box-shadow: -10px 3px 10px rgba(0, 0, 0, .23), 0 3px 10px rgba(0, 0, 0, .16);
}
I would classify myself as a beginner and discover answers through trial and error. However I can't solve this. I would like an image to be behind the h2 text on my homepage. I have tried placing it everywhere within here and nothing makes it show up.
Here is my site: http://bitsybride.com
Here is what I want: http://bitsybride.com/Image8.png
Here is the relevant css:
.smallpost {
overflow:hidden;
width:730px;
padding-bottom:0;}
ul.smallpost li {
width:290px;
height:130px;
margin:0 40px 60px 0;
padding:0px 0px 0px 0px;
position:relative;
float:left;
background: url(images/pink ribbon.png);}
ul.smallpost h2 {
font-size: 12pt;
line-height: 0pt;
margin: 0 0 0px 0;
padding:5px 0px 100px 15px;
letter-spacing: -1px;}
ul.smallpost li img {
margin:-20px 0 15px -20px;
width:280px;
height:150px;
overflow:hidden;
padding: 4px;
margin: 1px 1px 4px 1px;
overflow: hidden;
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); /*-moz-border-radius: 5px;-khtml- border-radius: 5px;-webkit-border-radius: 5px;border-radius: 5px;*/
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
-o-linear-gradient(#2F2727, #1a82f7);
background:
-moz-linear-gradient(center top , #FFFFFF, #EFEFEF) repeat scroll 0 0 transparent
;
background: -webkit-gradient(linear, left top, left bottom,
from(#fff),
color-stop(0.5, #fff),
to(#EFEFEF)
);
filter: progid: DXImageTransform.Microsoft.Gradient(StartColorStr='#ffffffff', EndColorStr='#EFEFEFEF');
-ms-filter: \"progid: DXImageTransform.Microsoft.gradient(startColorstr=#ffffffff, endColorstr=#EFEFEFEF)";
-o-linear-gradient(top, #dcdcdc, #c6c6c6);
border: 1px solid #FFFFFF;
z-index: 5;}
Help!
If you want your h2's to have a background image, try this in your ul.smallpost h2
background-image: url('/wp-content/uploads/2012/05/bitsy2.png');
or wherever your image is.
use display:inline-block in your h2 tag
ul.smallpost li {
width:290px;
height:130px;
margin:0 40px 60px 0;
padding:0px 0px 0px 0px;
position:relative;
float:left;
}
ul.smallpost h2 {
font-size: 12pt;
line-height: 0pt;
margin: 0 0 0px 0;
padding:5px 0px 100px 15px;
letter-spacing: -1px;
background: url(images/pink ribbon.png);
display:inline-block;
}
On my site http://goo.gl/BcJtC section "about us" I'd like the picture with the planet to be aligned horizontally in the middle of the DIV.
I tried text-align:center; but it doesn't work. Any idea? Thanks
HTML
<div class="section" id="plan-activite">
<div id="activity-container">
<div id="activity-left"><span class="activity-title">About Us</span><br /><img src="images/planet-water.jpg" class="activity-planet" alt="Picture" /></div>
<div id="activity-right"><p><span class="activity-conclusion">XYZ, naturlig mineralvann, ren natur</span></p><br /><p>XXZ AS was founded May 2011sdqsd.</p><br/>
</div>
</div>
</div><!--END page3-->
CSS
#activity-container
{
width:90%;
background-color:#FFFFFF;
Height:400px;
margin-left: auto;
margin-right: auto;
opacity:0.95;
filter:alpha(opacity=95); /* For IE8 and earlier */
border: 1px solid #efefef;
background: #fff;
-webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.27), 0 0 40px rgba(0, 0, 0, 0.06) inset;
-moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.27), 0 0 40px rgba(0, 0, 0, 0.06) inset;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.27), 0 0 40px rgba(0, 0, 0, 0.06) inset;
}
#activity-left {
color:#000;
margin: 0 auto;
border-style:solid;
border-right-color:#666;
padding:15px;
width: 30%;
float: left;
position: relative;
}
#activity-right {
font:12px 'Open Sans', "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight:400;
margin: O auto;
padding:15px;
color:#000;
width: 60%;
float: left;
position: relative;
text-align:justify;
-moz-column-count: 1;
-moz-column-gap: 1.5em;
-moz-column-rule: 1px solid #c4c8cc;
-webkit-column-count: 1;
-webkit-column-gap: 1.5em;
-webkit-column-rule: 1px solid #c4c8cc;
}
.activity-planet
{
text-align:center;
margin-top:20px;
margin-left:20px;
}
It will work if you set display: block and margin: 0 auto; to the img {
This page renders great in FF, Chrome, etc.. However in IE 7 and 8, the close "X" which is a background image does not line up. Any ideas? I tried to set the background-position etc..
The code I have:
.startup-container
{
width: 455px;
}
.close-startup-home
{
background: #c00 url("http://spotlightonhealthyliving.com/btn_closex.png") 0px -8px no-repeat;
float: right;
height: 52px;
width: 60px;
}
.menu-outer
{
background: #545454;
-moz-border-radius:5px;
border-radius:5px;
-moz-box-shadow: 0px 0px 5px 3px rgba(0, 0, 0, .4);
box-shadow: 0px 0px 5px 3px rgba(0, 0, 0, .4);
}
.menu-inner
{
background: #3f3f3f;
-moz-box-shadow: inset 0px 0px 4px 3px rgba(0, 0, 0, .1);
box-shadow: inset 0px 0px 4px 3px rgba(0, 0, 0, .1);
-moz-border-radius:5px;
border-radius:5px;
}
.startup-box
{
width:439px;
line-height:20px;
text-align: center;
color:#fff;
padding-top:5px;
padding-bottom:5px;
}
.startup-box-inner
{
width:389px;
height:99px;
padding:20px;
margin-left:5px;
margin-right:5px;
}
<div class="startup-container">
<div class="close-startup-home"></div>
<div class="menu-outer startup-box">
<div class="menu-inner startup-box-inner"></div>
</div>
</div>
Give a position: absolute to your div containing the close button and position it according to that.
.startup-container {
width: 455px;
position: relative
}
.close-startup-home {
background: #c00 url("http://spotlightonhealthyliving.com/btn_closex.png") 0px -8px no-repeat;
float: right;
height: 52px;
width: 60px;
position: absolute;
right: 0;
}