Please help, I am trying to simply add a border at the last element of my sub menu and text indent for the sub-menu elements, but for some reason it just applies everything on the top of the page, please take a look at the image below, it applies the changes on the top of the page for some reason and not on the elements it self!
for Live preview: http://leo.meeped.co.uk/
Thanks in advance.
Here is the HTML code:
<header>
<div id="wrapperHeader">
<div class="scrollable" id="headerContent">
<section class="headerLogo">
<img id="logoImage" src="assets/elements/logo.png" alt="LOAI Design Studio Logo"/>
</section>
<section id="headerMenu">
<nav id="MainMenu">
<ul class="MainMenu">
<li><a class="active" href="index.html">Home</a></li>
<li><a class="SubMenu" href="#">Portfolio</a>
<ul class="subMenu">
<li>Web Design</li>
<li>Visual Identity</li>
<li>Photography</li>
</ul>
</li>
<li>Testimonials</li>
<li>About Me</li>
<li>Get In Touch</li>
<li><a class="getStartedButton" href="get-started.html">Get Started</a></li>
</ul>
</nav>
</section>
</div>
</div>
</header>
Here's the CSS Code:
body{
line-height: 120%;
}
/*Additions*/
.scrollable{
overflow: auto;
-webkit-transition-property: top, bottom;
transition-property: top, bottom;
-webkit-transition-duration: .2s, .2s;
transition-duration: .2s, .2s;
-webkit-transition-timing-function: linear, linear;
transition-timing-function: linear, linear;
-webkit-overflow-scrolling: touch;
}
/*Pages Overall Styling*/ #Page{
position: relative;
padding-top: 0px;
z-index: 2;
-webkit-box-shadow: -3px 0px 20px rgba(0, 0, 0, 0.25);
-moz-box-shadow: -3px 0px 20px rgba(0, 0, 0, 0.25);
box-shadow: -3px 0px 20px rgba(0, 0, 0, 0.25);
}
/*Content Containers Overall Styling*/.content{
width: 800px;
}
/*Header Containers Overall Styling*/#headerContent{
max-width: 100%;
height: 100%;
position: fixed;
margin: auto;
}
#wrapperHeader{
background-color: #2D3B53;
border-bottom: none;
width: 230px;
height: 100%;
position: fixed;
padding: 0px;
z-index: 1;
}
/*Main Header Elements*/
.headerLogo, #LogoImage{
display: none;
}
#headerMenu{
max-width: 230px;
float: none;
}
/*Main Menu*/
#MainMenu li{
padding: 0px;
float: none;
}
#MainMenu a{
color: #E0E5EE;
border-bottom: 1px solid #253145;
width: 100%;
line-height: 50px;
text-align: left;
text-indent: 20px;
float: left;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
#MainMenu a:hover{
color: #B8C4D8;
background-color: #3D567B;
}
#MainMenu a.active{
display: none;
}
#MainMenu li a.getStartedButton{
color: #74ADB4;
}
#MainMenu li a.getStartedButton:hover{
background-color: #74ADB4;
color: #D4E6E8;
}
/*SubMenu*/
ul.subMenu{
background-color: #33435F;
border: 1px solid #DDDDDD;
display: none;
padding: 0;
position: relative;
top: 0; left: 0;
-webkit-box-shadow: 0px 4px 15px -5px rgba(0,0,0,0.43);
-moz-box-shadow: 0px 4px 15px -5px rgba(0,0,0,0.43);
box-shadow: 0px 4px 15px -5px rgba(0,0,0,0.43);
}
.subMenu li{
width: 230px;
border-bottom:1px solid #DDDDDD;
}
/*Second Header Container & Elements (Hidden From Widescreen)*/
#SecondHeader{
background-color: #3D5273;
width: 100%;
line-height: 50px;
text-align: left;
display: inline-block;
}
.SecondHeader-button{
color: #FFFFFF;
background: #3D5273 url('../../assets/elements/nav-icon.png') no-repeat 10px center;
font-size: 15px;
font-weight: bold;
text-indent: 45px;
display: inline-block;
}
/*////////////////////////////*/
Use pseudo class :last-child like this:
nav ul li:last-child {
//style
}
Are subMenu and SubMenu the same thing? If so, you need to change that in your HTML. Maybe that's the answer to your problem?
Related
I am playing with CSS pseudo elements. As soon as the menu button gets hovered it receives a small orange underline. This element should stay as soon as the dropdown-container is visible. Is there a light weight solution to achieve such behaviors?
In case pseudo elements arenĀ“t the best solution for my need, I am open minded for different solutions.
https://jsfiddle.net/j3g49fwd/
$(".dropdown-btn").click(function() {
this.classList.toggle("increase")
$(".dropdown-container").toggle()
})
.wrapper {
position: relative;
top: 5vh;
margin: 40px 30px 30px 30px;
height: fit-content;
background: white;
border-radius: 10px;
box-shadow: -10px -10px 10px rgba(255, 255, 255, 0.5),
15px 15px 15px rgba(70, 70, 70, 0.12);
padding: 1vw;
}
.dropdown-btn {
display: flex;
justify-content: center;
padding: 10px 0px 10px 20px;
text-decoration: none;
display: block;
border: 1px solid transparent;
background: none;
height: fit-content;
min-height: 5vh;
width: 100%;
text-align: left;
cursor: pointer;
outline: none;
transition: all 0.3s ease-in-out;
}
.dropdown-btn:after {
content: "";
display: block;
margin: 3px 0 0 0;
width: 0;
height: 1px;
background: rgb(242, 123, 57);
transition: all 0.4s;
}
.dropdown-btn:hover::after {
width: 100%;
}
.dropdown-container {
display: none;
padding: 10px 20px 10px 20px;
margin: 0 0 2vh 0;
}
.increase {
font-size: 20px !important;
}
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
</head>
<body>
<div class="wrapper">
<button class="dropdown-btn">I am a menu button
<label class="menu-title" id="flow-menu-title"></label>
<i class="fa-solid fa-gear col-1 dropdown-icon"></i>
</button>
<div class="dropdown-container">
Hello Stackoverflow
</div>
</div>
</body>
</html>
if I understand you correctly, you should be able to edit the CSS just like this:
.dropdown-btn.increase::after,.dropdown-btn:hover::after {
width: 100%;
}
https://jsfiddle.net/bkefg9dt/
So how do I make a dropdown menu using this css? Tried some tuts, but with this css I can't get any of those dropdowns working ;(.
CSS:
.main {
list-style: none;
margin: 0;
margin-bottom: 100px;
padding: 0px;
height: 44px;
text-decoration: none;
background-color: #171a21;
width: 100%;
text-align: left;
font-size: 18px;
-webkit-box-shadow: 0px 0px 8px rgba(0, 6, 0, 0.45);
-moz-box-shadow: 0px 0px 8px rgba(0, 6, 0, 0.45);
box-shadow: 0px 0px 8px rgba(0, 6, 0, 0.45);
}
.main li {
float: left;
padding: 16px;
margin: 0;
line-height: 17px;
height: 16px;
margin-bottom: -6px;
margin-left: 45px;
list-style:none;
}
.main p {
float: left;
margin: 0;
padding: 0;
line-height: 17px;
height: 44px;
margin-bottom: -6px;
}
.main a {
display: block;
color: #b8b6b4;
text-decoration: none;
transition: all linear 0.15s;
}
.main a:hover {
display: block;
color: white;
text-decoration: none;
}
HTML:
<ul class="main">
<li>Test
<ul>
<li>Test1</li>
<li>Test2</li>
<li>Test3</li>
</ul>
</li>
</ul>
I'm just starting with html&css and making a site.
Thanks for any help ;).
Check this Fiddle:
The key is in those lines of CSS code:
.main li ul {
display: none;
}
.main li:hover > ul {
display: block;
}
Should be quite self explicative.
add these lines to your css file:
.main li ul {display: none;}
.main li:hover ul {display: block;}
Hello ...
How could Make link wraps with the end of the cell ?
because if the text contains links turn to a new line as shown in the picture,
So - If the div is 400px x 300px. If text enters more than 400px then the text take new line put not just the link.
like
i need it in css.
thnx ,
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<style type="text/css">
#menu {
padding: 10px;
margin: 5px 5px 5px 5px;
}
#menu a {
width: 140px;
}
#menu ul {
white-space: wrap;
list-style-type: none;
}
#menu li {
white-space: wrap;
float: right;
position: relative;
text-align: center;
}
#menu ul.sub-menu {
white-space: wrap;
position: absolute;
left: -10px;
z-index: 90;
display:none;
}
#menu ul.sub-menu li {
text-align: right;
}
#menu li:hover ul.sub-menu {
display: block;
}
.egg{
white-space: wrap;
padding: 10px;
margin: 5px 5px 5px 5px;
position:relative;
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
background-color:#fff;
border-radius: 3px 3px 3px 3px;
border: 1px solid rgba(100, 100, 100, 0.4);
}
.egg_Body{border-top:1px solid #D1D8E7;color:#808080;}
.egg_Message{font-size:13px !important;font-weight:normal;overflow:hidden}
h3{font-size:13px;color:#333;margin:0;padding:0}
.comment_ui
{
white-space: wrap;
padding: 10px;
margin: 5px 5px 5px 5px;
border-bottom:1px solid #e5eaf1;clear:left;float:none;overflow:hidden;padding:6px 4px 3px 6px;width:331px; cursor:pointer;
}
.comment_ui:hover{
white-space: wrap;
background-color: #F7F7F7;
padding: 10px;
margin: 5px 5px 5px 5px;
}
.dddd
{
white-space: wrap;
padding: 10px;
margin: 5px 5px 5px 5px;
background-color:#f2f2f2;border-bottom:1px solid #e5eaf1;clear:left;float:none;overflow:hidden;margin-bottom:2px;padding:6px 4px 3px 6px;width:431px;
}
.comment_text{padding:2px 0 4px; color:#333333}
.comment_actual_text{display:inline;padding-left:.4em}
ol {
list-style:none;
margin:0 auto;
width:500px;
margin-top: 20px;
}
#mes{
white-space: wrap;
padding: 0px 3px;
border-radius: 2px 2px 2px 2px;
background-color: rgb(240, 61, 37);
font-size: 9px;
font-weight: bold;
color: #fff;
top: -5px;
left: -73px;
}
.toppointer{
background-image:url(alert/top.png);
background-position: -82px 0;
background-repeat: no-repeat;
height: 11px;
position: absolute;
top: -11px;
width: 20px;
right: 354px;
}
</style>
<div id="menu">
<ul>
<li>
<a href="#" style="padding:10px 0;">
<img src="alert/images.png" style="width: 21px;" />
<span id="mes">$count</span>
</a>
<ul class="sub-menu">
<li class="egg">
<div class="toppointer"><img src="alert/top.png" /></div>
<div id="view_comments $id"></div>
<div id="two_comments $id">
<div class="comment_ui">
<div class="comment_text">
<div class="comment_actual_text">
$all
</div></div></div></div>
<div class="bbbbbbb" id="view $id">
<div style="background-color: #F7F7F7; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; position: relative; z-index: 100; padding:8px; cursor:pointer;">
View all $comment_count comments
</div>
</div>
</li>
</ul>
</li>
</ul>
</div>
I may not be reading the question correctly, but if you want the links to sit on their own line, you can just set them to display: block;. E.g.
li a {display: block;}
This is a .header class with a background image, and navigation in the tag. What I am
trying to do is separate the background image from .header and place it in a new div (that will
go behind the navigation, but keep the same position as is) so I can
add some filters and customise it further.
<style>
.header {
float: left;
height: 300px;
width: 100%;
margin-top: 2%;
-webkit-border-top-left-radius: 6px;
-webkit-border-top-right-radius: 6px;
-moz-border-radius-topleft: 6px;
-moz-border-radius-topright: 6px;
background-image: url(../5898169717_6f4b2a3515_b.jpg);
background-position: center center;
background-repeat: no-repeat;
background-size: auto;
background-color: #91918e;
}
.header .nav-header { margin-top: 15px; padding-left: 30px; padding-right: 50px; }
.header .nav-header #navigation {
float: left;
position: relative;
}
.header .nav-header #navigation li {
position: relative;
list-style: none;
display: inline-block;
margin-top: 5px;
}
.header .nav-header #navigation li a {
padding: 0 inherit;
padding-left: 10px;
padding-right: 10px;
display: inline-block;
font-family: 'Open Sans', Arial, Helvetica, sans-serif;
text-shadow: 1px 1px 2px #242526, 0 0 1em #242526, 0 0 0.2em #242526;
text-decoration: none;
font-size: 14px;
font-weight: 700;
color: white;
text-align: left;
transition-property: color;
transition-duration: 100ms;
transition-timing-function: linear;
-webkit-transition-property: color;
-webkit-transition-duration: 100ms;
-webkit-transition-timing-function: ease-out;
-moz-transition-property: color;
-moz-transition-duration: 100ms;
-moz-transition-timing-function: ease-out;
-o-transition-property: color;
-o-transition-duration: 100ms;
-o-transition-timing-function: ease-out;
-ms-transition-property: color;
-ms-transition-duration: 100ms;
-ms-transition-timing-function: ease-out;
}
.header .nav-header #navigation li a:last-child {}
.header .nav-header #navigation li:hover .main { color: #f0b92d;}
/** Dropdown **/
.header .nav-header #navigation li .sub-nav-wrapper {
display: block;
position: absolute;
z-index: 30;
margin-left: -16px;
}
.header .nav-header #navigation li .sub-nav-wrapper .sub-nav {
width: 150px;
margin-top: 10px;
background: white;
border-top: 1px solid #91918e;
box-shadow: 0 1px 2px #91918e;
-moz-box-shadow: 0 1px 2px #91918e;
-webkit-box-shadow: 0 1px 2px #91918e;
}
.header .nav-header #navigation li .sub-nav-wrapper .sub-nav:first-child { border: none; }
.header .nav-header #navigation li:hover .sub-nav-wrapper { display: block; }
.header .nav-header #navigation li .sub-nav-wrapper .sub-nav li {
list-style: none;
display: block;
margin: 0;
padding: 0;
text-align: left;
border-bottom: 1px solid #91918e;
}
.header .nav-header #navigation li .sub-nav-wrapper .sub-nav li:last-child { border: none; }
.header .nav-header #navigation li .sub-nav-wrapper .sub-nav li a {
display: block;
color: #242526;
text-decoration: none;
text-shadow: 1px 1px 2px white, 0 0 1em white, 0 0 0.2em white;
padding: 11px 20px;
font-size: 12px;
font-weight: 600;
box-shadow: inset 0 0 2px rgba(255,255,255,1.0);
-moz-box-shadow: inset 0 0 2px rgba(255,255,255,1.0);
-webkit-box-shadow: inset 0 0 2px rgba(255,255,255,1.0);
}
.header .nav-header #navigation li .sub-nav-wrapper .sub-nav li:hover {
background: #dcdbd2;
}
.header .nav-header a, #navigation li .sub-nav-wrapper .sub-nav li { }
.header .nav-header #navigation li .sub-nav-wrapper {
pointer-events: none;
opacity: 0;
filter: alpha(opacity=0);
top: 0;
}
.header .nav-header #navigation li:hover .sub-nav-wrapper {
pointer-events: auto;
opacity: 1;
filter: alpha(opacity=100);
top: 15px;
}
</style>
<section class="header">
<nav class="nav-header">
<ul id="navigation">
<li>
Home
</li>
<li>
Portfolio
<div class="sub-nav-wrapper"><ul class="sub-nav">
<li>Graphics</li>
<li>Web</li>
<li>Print</li>
</ul></div>
</li>
<li>
Services
<div class="sub-nav-wrapper"><ul class="sub-nav">
<li>Web Design</li>
<li>SEO</li>
<li>Content Writing</li>
</ul></div>
</li>
<li>
Technology
<div class="sub-nav-wrapper"><ul class="sub-nav">
<li>JavaScript</li>
<li>HTML/CSS</li>
<li>Drupal</li>
<li>Joomla</li>
<li>Wordpress</li>
<li>MySQL</li>
<li>Oracle</li>
</ul></div>
</li>
<li>
About
<div class="sub-nav-wrapper"><ul class="sub-nav">
<li>Location</li>
<li>History</li>
<li>Jobs</li>
<li>Awards</li>
</ul></div>
</li>
<li>
Contact
</li>
</ul>
</nav>
</section>
You're going to need to add a child to the .header element with a z-index: -1, and make sure the .header has the CSS position: relative;
Here's a working jsfiddle of your code working the way you want.
To your markup, as the first child of .header I added:
<div class="inner-header"></div>
And to your CSS, I added at the bottom:
.header {
background-image: none;
background-color: transparent;
position: relative;
}
.inner-header {
background-image: url('http://upload.wikimedia.org/wikipedia/commons/7/7d/Haeckel_Siphoneae.jpg');
background-size: 100% auto;
-webkit-border-top-left-radius: 6px;
-webkit-border-top-right-radius: 6px;
-moz-border-radius-topleft: 6px;
-moz-border-radius-topright: 6px;
border-top-left-radius: 6px;
border-top-right-radius: 6px;
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 100%;
z-index: -1;
}
How about this: http://jsfiddle.net/Xm5BE/
Here is the HTML:
<header>
<div class="nav">
<ul>
<li>Link 1</li>
<li>Link 1</li>
<li>Link 1</li>
<li>Link 1</li>
</ul>
</div>
<div class="header">This is the header bg div</div>
</header>
and the CSS:
header { background:black ;
width:100% ;
height:200px ;
position:relative ;
}
.header { position:absolute ;
left:0 ;
top:0 ;
width:100% ;
height:200px ;
background:blue ;
z-index:100 ;
}
.nav { width:100% ;
height:28px ;
background:yellow ;
position:relative ;
top:120px ;
z-index:500 ;
}
.nav ul { margin-left:0 ;
padding-left:0 ;
list-style-type:none ;
text-align:center ;
}
.nav li { display:inline ;
}
.nav li a { padding:0px 8px ;
line-height:28px ;
font-size:14px ;
font-family:arial ;
}
I'm having an issue with some CSS I'm working on. The expected content is to be a containing box with four rounded corners that everything falls into. It works in Safari on the Mac, but not in Chrome or in iOS. In those browsers, the corners are squared for the .posttype and the image. I can't seem to figure out what is causing the issue. Any help will be great.
CSS:
.row { margin-bottom: 50px; }
.box { background: #eee; }
.shadow { -moz-box-shadow: 0px 3px 3px 0px #666; -webkit-box-shadow: 0px 3px 3px 0px #666; box-shadow: 0px 3px 3px 0px #666; }
.rounded { border-radius: 10px; -webkit-border-radius: 10px; -moz-border-radius: 10px; display: block; overflow: hidden; }
.posttype {
float: right;
position: relative;
width: 150px;
height: 150px;
text-transform: uppercase;
margin: -85px -85px 4px 4px;
-moz-transform: rotate(45deg);
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform:rotate(45deg);
overflow: hidden;
}
.posttype > p {
position: absolute;
bottom: 0;
width: 100%;
text-align: center;
font-size: 24px;
text-shadow: -1px -1px 1px #fff, 1px 1px 1px #000;
color: #fff;
opacity: 0.3;
}
.meta {
width: 110%;
margin: 5px -8px -8px -8px;
padding: 5px;
background-color: rgba(255,255,255,0.8);
box-shadow: inset -5px 1px 5px #555;
font-size: 10pt;
color: #555;
}
.photo { position: relative; }
.photo > p { padding: 0 8px; }
.photo > .meta { padding-left: 16px; padding-bottom: 16px; }
.photo > img, .photo > a > img { width: 100%; margin-bottom: 10px; }
.photo > .posttype { position: absolute; top: 0; right: 0; margin: -75px -75px 4px 4px; }
HTML:
<div class="row">
<div class="span7 box rounded shadow photo">
<img src="photo.jpg" alt="Alt" width="500">
<div class="posttype"><p>photo</p></div>
<p>This is a great picture.</p>
<hr class="clear">
<div class="meta">
<ul>
<li class="date"><i class="icon-time"></i> 7/29/12</li>
<li class="comments"><i class="icon-comment"></i> 3 Comments</li>
</ul>
<hr class="spacer">
<ul class="tags">
<li class="tags"><i class="icon-tags"></i></li>
<li class="tag">Tag1</li>
<li class="tag">Tag2</li>
</ul>
</div>
</div>
</div>
Live demo: Tinkerbin
The round borders are behind the image, add a padding-top look at this http://tinkerbin.com/fLyD5Cuf