How to add an image to list items in Html? - html

I have the following html code for a simple menu:
<div class="wHeader">
<div class="header">
<img src="header.png">
</div><!-- header ends here -->
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li class="current-item">Home</li>
<li>
Language
<ul class="sub-menu">
<li><a href=#>Lang1</a></li>
<li><a href=#>Lang2</a></li>
<li>Other ...</li>
</ul>
</li>
</ul>
</nav>
</div> <!-- menu-wrap ends here-->
The CSS style for <ul> is as follows:
.sub-menu {
width:120%;
padding:5px 0px;
position:absolute;
top:100%;
left:0px;
z-index:-1;
opacity:0;
transition:opacity linear 0.15s;
background:#808080;
}
I'm trying to put a flag image in one of the list items like this:
<li style="list-style-image: url('smallflag.png');">Lang1</li>
But so far the image is not appearing. Is there any conflict with background? Any suggestions to solve this?

.sub-menu {
width:120%;
padding:5px 0px;
position:absolute;
/*top:100%;*/
<!--left:0px;-->
z-index:-1;
/*opacity:0;*/
transition:opacity linear 0.15s;
background:#808080;
}
<div class="wHeader">
<div class="header">
<!--<img src="header.png">-->
</div><!-- header ends here -->
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li class="current-item">Home</li>
<li>
Language
<ul class="sub-menu">
<li><a href=#>Lang1</a></li>
<li><a href=#>Lang2</a></li>
<li style="list-style-image: url('http://placehold.it/20x20');">Other ...</li>
</ul>
</li>
</ul>
</nav>
</div>
The sub-menu class is hiding it and moving it to the bottom of the screen, also the picture is lost with the left:0px property.
If you comment out the top:100%, left:0 and opacity properties, the item will show with its image

Related

How to get a div overlapping another

<header>
<div>
<h1>Midorikawa's Site</h1>
<hr />
<!--<p>Work in progress</p>-->
<nav>
<ul>
<li><a class="active" href="#">Home</a></li>
<li>Blog</li>
<li>Quote</li>
<li>Photographs</li>
<li>Contact</li>
</ul>
</nav>
</div>
<div id="wallpaper"></div><!-- THIS div has to go underneath the other div -->
</header>
the "wallpaper" div has to go underneath the other div the "wallpaper" div is javascript activated and switches wallpaper with an fade but i have no idea how to get it underneath the other div please help
Use position: absolute on the first div:
Refer code:
<header>
<div class="content">
<h1>Midorikawa's Site</h1>
<hr />
<!--<p>Work in progress</p>-->
<nav>
<ul>
<li><a class="active" href="#">Home</a></li>
<li>Blog</li>
<li>Quote</li>
<li>Photographs</li>
<li>Contact</li>
</ul>
</nav>
</div>
<div id="wallpaper"></div><!-- THIS div has to go underneath the other div -->
</header>
CSS
.content {
position: absolute;
left: 0;
right: 0;
margin: auto;
text-align: center;
}
.body {
position: relative;
}
Use position: absolute; on both children of <header>.
Use positive z-index on the div you want on top.
jsFiddle: https://jsfiddle.net/sukritchhabra/89f1est4/
Use css property z-index on your divs. The one which you need on top should have higher z-index than the one that should be underneath it (I coloured the divs for visual).
<div style="position:absolute">
<h1>Midorikawa's Site</h1>
<hr />
<nav>
<ul>
<li><a class="active" href="#">Home</a></li>
<li>Blog</li>
<li>Quote</li>
<li>Photographs</li>
<li>Contact</li>
</ul>
</nav>
</div>
<div id="wallpaper" style="width:50px;height:100px;background-color:red;z- index:-5"></div>

Sliding down dropdown using css only

I am trying to sliding down a sub menu. The reference which I am following is -- https://codepen.io/shshaw/pen/gsFch
But the dropdown doesn't slide. It just appears on hover.
Html code --
<nav id="main-nav" class="clearfix">
<div class="nav-inner clearfix">
<div class="menu-main-navigation-container">
<ul id="nav" class="clearfix page">
<li class="item">
Menu
<ul class="sub-menu">
<li class="item">Sub Menu 1</li>
<li class="item">Sub Menu 2</li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
Demo -- https://jsfiddle.net/squidraj/seqc1w9f/6/
Any help is highly appreciated.
display cannot be animated. This needs to be removed.
ul#nav li ul {
display: none;

Dropdown menu doesn't become visible on .drop:hover

I'm creating a menu, where if I hover over the li class="drop", then the visibility of my #competences-dropdown should become visible, but it doesn't wanna work for some reason. Can someone please help by telling what didn't I noticed?
.drop:hover #competences-dropdown {
visibility:visible;
}
#competences-dropdown {
background-color:rgba(51,51,51,0.8);
width:100%;
padding-right:100px;
position:absolute;
z-index:3;
visibility:hidden;
-webkit-transition:1s;
display:block;
}
<div id="menu">
<ul class="navigation">
<li>Forside</li>
<li class="drop">Kompetencer</li>
<li>Om Magento</li>
<li>Teamet</li>
<li>Cases</li>
<li>Blog</li>
<li>Kontakt</li>
</ul>
</div>
<div id="competences-dropdown">
<div class="row">
<div class="col-sm-12">
<ul class="dropdown">
<li><a href="">
<h1>WEBUDVIKLING</h1>
<img class="img-responsive" src="img/dropdown/webdev.png" alt="Webdev"/>
</a></li>
<li><a href="">
<h1>DESIGN</h1>
<img class="img-responsive" src="img/dropdown/design.png" alt="Design"/>
</a></li>
<li><a href="">
<h1>MARKETING</h1>
<img class="img-responsive" src="img/dropdown/marketing.png" alt="Marketing"/>
</a></li>
</ul>
</div>
</div>
</div>
of cousre it doesn't work as your css says:
.drop:hover #competences-dropdown {
visibility:visible;
}
which means #competences-dropdown is a child of .drop, which it is not.
so the solution would be making #competences-dropdown a child of .drop as follows, and everything should work fine:
.drop:hover #competences-dropdown {
visibility:visible;
}
#competences-dropdown {
background-color:rgba(51,51,51,0.8);
width:100%;
padding-right:100px;
position:absolute;
z-index:3;
visibility:hidden;
-webkit-transition:1s;
display:block;
}
<div id="menu">
<ul class="navigation">
<li>Forside</li>
<li class="drop">
Kompetencer
<div id="competences-dropdown">
<div class="row">
<div class="col-sm-12">
<ul class="dropdown">
<li>
<a href="">
<h1>WEBUDVIKLING</h1>
<img class="img-responsive" src="img/dropdown/webdev.png" alt="Webdev"/>
</a>
</li>
<li>
<a href="">
<h1>DESIGN</h1>
<img class="img-responsive" src="img/dropdown/design.png" alt="Design"/>
</a>
</li>
<li>
<a href="">
<h1>MARKETING</h1>
<img class="img-responsive" src="img/dropdown/marketing.png" alt="Marketing"/>
</a>
</li>
</ul>
</div>
</div>
</div>
</li>
<li>Om Magento</li>
<li>Teamet</li>
<li>Cases</li>
<li>Blog</li>
<li>Kontakt</li>
</ul>
</div>
Try to use
.drop:hover {
visibility:visible;
}
Maybe you should try opacity instead of visibility
Also do put the :hover always at the end of your code like this
.example #example:hover{}
And not
.example:hover #example{}

menu on rightside and Logo on left in a semi-transparent navigation bar

I need a navbar which is semi transparent over the background image.
Logo on left side and menu on right-side which should be equally spaced between list items.Something like -
https://getbootstrap.com/examples/cover/
http://bootsnipp.com/snippets/featured/full-screen-background-cover-page
I tried giving float:right to my <ul> element of menulist, it goes to the right extreme.
HTML
<body>
<nav>
<ul style="float:right;">
<li style="display:inline;">item1</li>
<li style="display:inline;">item2</li>
<li style="display:inline;">item3</li>
<li style="display:inline;">item4</li>
</ul>
</nav>
</body>
CSS
body {
background-image:url("giphy.gif");
background-repeat: no-repeat;
background-size: cover;
overflow-x:hidden;
}
nav {
height:60px;
width:100%;
overflow-y:hidden;
overflow-x:hidden;
z-index:1;
background-color: transparent;
}
Using Bootstrap css, You can do it as
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">Your LOGO here.</a>
</div>
<ul class="nav navbar-nav" style="float:right">
<li class="active">Home</li>
<li>Page 1</li>
<li>Page 2</li>
<li>Page 3</li>
</ul>
</div>
</nav>
</body>
Hope this helps!

Insert image at right of dropdown on Boostrap

I'm using Bootstrap to create a navbar in the top of the page, but i'm facing some problems:
After opening the navbar dropdown, I need to have a option list, and a image positioned to the right of the list. This image needs to have the same height of the list, just like in the following image (in portuguese, but easily understandable).
I achieved this setting a fixed height and width on the image, but the list can grow up and isn't a good option adjust it manually.
Another solution is to insert a div containing the list and the image, and set the image size to 100%, but when I do this, the dropdown isn't achieved anymore (I think i'm breaking the structure that Bootstrap uses to toggle the dropdown, am I right?).
How can I achieve this solution?
<div id="navbar" class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav top-elements">
<li id="dropdown-produtos" class="dropdown">
Nossos Produtos<span class="caret top-caret"></span>
<!-- div was here --> <ul class="dropdown-menu dropdown-menu-produtos">
<li class="dropdown-item-active">
texto1
<ul class="dropdown-menu img-dropdown">
<img src="assets/img.png">
</ul>
</li>
<li class="dropdown-item">
texto2
</li>
<li class="dropdown-item">texto3</li>
<li class="dropdown-item">texto4</li>
<li class="dropdown-item">texto5</li>
</ul>
</li>
</ul>
</div>
This should work:
<ul class="nav navbar-nav">
<li>Elemento 1</li>
<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">DropDown<span class="caret"></span></a>
<ul class="dropdown-menu another-class">
<!-- ROW -->
<div class="col-md-12">
<!-- Column 1 -->
<div class="col-md-6">
<ul class="list-unstyled">
<li>Texto 1</li>
<li>Texto 2</li>
<li>Texto 3</li>
</ul>
</div>
<!-- Column 2 -->
<div class="col-md-6">
<div class="drop-image">
<img src="./img/img.jpg" class="img-responsive" />
</div>
</div>
</div>
</ul>
</li>
<li>Elemento 2</li>
<li>Elemento 3</li>
</ul>
Basically what I'm doing is create a div with a full width inside the dropdown element that comes as default in Boostrap. Inside this Full width row I create two columns with bootstrap col-md-6 class (you can do this with col-lg or col-sm or col-xs too) Inside this columns I add my content normally.
I created a class in the column 2 named "drop-image"; use this class to modify the img inside.
Hope it helps!
Btw, don't forget to style your dropdown (in the example I mark it with a class named another-class) so you define the position and width.
This might solve your problem, it's based off this plugin Yamm3!. See example Snippet.
Change this CSS rule if you need to make the dropdown wider because of the length of the link text. >
.list-unstyled, .list-unstyled ul {
min-width: 180px
}
body {
padding-top: 60px;
color: #666;
}
/* menu styes */
.list-unstyled,
.list-unstyled ul {
min-width: 180px
}
.list-unstyled > li {
padding-top: 10px;
}
.list-unstyled > li > a {
color: #555;
text-decoration: none;
}
.yamm .nav,
.yamm .collapse,
.yamm .dropup,
.yamm .dropdown {
position: static;
}
.yamm .container {
position: relative;
}
.yamm .dropdown-menu {
left: auto;
background: #f5f5f5;
}
.yamm .yamm-content {
padding: 0 30px 10px 30px;
}
.yamm .yamm-content .nav-title {
margin-left: 15px;
}
.yamm .dropdown.yamm-fw .dropdown-menu {
left: 0;
right: 0;
}
#media (max-width: 767px) {
.yamm-content .list-unstyled > li img {
margin-top: -180px;
float: right;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="navbar yamm navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" data-toggle="collapse" data-target="#navbar-collapse-1" class="navbar-toggle"><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span>
</button>Grande Menu
</div>
<div id="navbar-collapse-1" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<!-- Classic list -->
<li class="dropdown">Nossos Produtos<b class="caret"></b>
<ul class="dropdown-menu">
<li>
<!-- Content container to add padding -->
<div class="yamm-content">
<div class="row">
<h4 class="nav-title"><strong>A partida de um</strong></h4>
<ul class="col-sm-4 list-unstyled">
<li>Vinculando um
</li>
<li>Ligando dois
</li>
<li>Ligação de três
</li>
<li>Quatro ligação
</li>
<li>Ligação cinco
</li>
<li>Seis ligação
</li>
</ul>
<ul class="col-sm-2 list-unstyled">
<li>
<img src="http://placehold.it/150x150/ff0/fff">
</li>
</ul>
</div>
</div>
</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav">
<!-- Classic list -->
<li class="dropdown">Nossos Produtos Dois<b class="caret"></b>
<ul class="dropdown-menu">
<li>
<!-- Content container to add padding -->
<div class="yamm-content">
<div class="row">
<h4 class="nav-title"><strong>A partida de um</strong></h4>
<ul class="col-sm-4 list-unstyled">
<li>Vinculando um
</li>
<li>Ligando dois
</li>
<li>Ligação de três
</li>
<li>Quatro ligação
</li>
<li>Ligação cinco
</li>
<li>Seis ligação
</li>
</ul>
<ul class="col-sm-2 list-unstyled">
<li>
<img src="http://placehold.it/150x150/ff0/fff">
</li>
</ul>
</div>
</div>
</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
<div class="container">
<div class="alert alert-warning">Olá</div>
</div>