I'm trying to create a header hero but my problem is that my background image goes on all my contents. Actually it has lower z-index than content but I don't know why doesn't it go on background.
.header
{
width: 100vw;
background-color: blue;
position: relative;
}
.headerbakground
{
position: absolute;
width: 100%;
z-index: 1;
}
.header ul li img,.header ul li
{
width: 2vw;
float: right;
}
.header .container
{
z-index: 2;
}
<div class="header">
<!--background image-->
<img src="https://www.renonation.sg/wp-content/uploads/2015/01/title-header-hero-01.jpg" class="headerbakground">
<!--header top-->
<div class="container">
<ul>
<li><img src="https://d30y9cdsu7xlg0.cloudfront.net/png/1832-200.png" ></li>
<li><img src="https://d30y9cdsu7xlg0.cloudfront.net/png/1832-200.png" ></li>
<li><img src="https://d30y9cdsu7xlg0.cloudfront.net/png/1832-200.png" ></li>
<li><img src="https://d30y9cdsu7xlg0.cloudfront.net/png/1832-200.png" ></li>
<li><img src="https://d30y9cdsu7xlg0.cloudfront.net/png/1832-200.png" ></li>
</ul>
</div>
</div>
Only a positioned element can use z-index. According to MDN:
The z-index property specifies the z-order of a positioned (that is, one with any position other than static) element and
its descendants.
The .container doesn't have a position, so the z-index: 2 is ignored. Add position: relative to it:
.header .container {
position: relative;
z-index: 2;
}
.header {
width: 100vw;
background-color: blue;
position: relative;
}
.headerbakground {
position: absolute;
width: 100%;
z-index: 1;
}
.header ul li img,
.header ul li {
width: 10vw;
float: right;
}
.header .container {
position: relative;
z-index: 2;
}
<div class="header">
<!--background image-->
<img src="https://www.renonation.sg/wp-content/uploads/2015/01/title-header-hero-01.jpg" class="headerbakground">
<!--header top-->
<div class="container">
<ul>
<li>
<img src="https://d30y9cdsu7xlg0.cloudfront.net/png/1832-200.png">
</li>
<li>
<img src="https://d30y9cdsu7xlg0.cloudfront.net/png/1832-200.png">
</li>
<li>
<img src="https://d30y9cdsu7xlg0.cloudfront.net/png/1832-200.png">
</li>
<li>
<img src="https://d30y9cdsu7xlg0.cloudfront.net/png/1832-200.png">
</li>
<li>
<img src="https://d30y9cdsu7xlg0.cloudfront.net/png/1832-200.png">
</li>
</ul>
</div>
</div>
You can also use a negative z-index: -1 on the element you want to push back:
.headerbakground {
position: absolute;
width: 100%;
z-index: -1;
}
.header {
position: relative;
width: 100vw;
background-color: blue;
}
.headerbakground {
position: absolute;
width: 100%;
z-index: -1;
}
.header ul li img,
.header ul li {
width: 10vw;
float: right;
}
<div class="header">
<!--background image-->
<img src="https://www.renonation.sg/wp-content/uploads/2015/01/title-header-hero-01.jpg" class="headerbakground">
<!--header top-->
<div class="container">
<ul>
<li>
<img src="https://d30y9cdsu7xlg0.cloudfront.net/png/1832-200.png">
</li>
<li>
<img src="https://d30y9cdsu7xlg0.cloudfront.net/png/1832-200.png">
</li>
<li>
<img src="https://d30y9cdsu7xlg0.cloudfront.net/png/1832-200.png">
</li>
<li>
<img src="https://d30y9cdsu7xlg0.cloudfront.net/png/1832-200.png">
</li>
<li>
<img src="https://d30y9cdsu7xlg0.cloudfront.net/png/1832-200.png">
</li>
</ul>
</div>
</div>
Related
I have an element on the page with horizontally scrolled content, scrollbar across the top.
This is working in FF/Chrome, and partially working in Safari.
The issue in Safari is the scroll bar is present & functional, but not visible. In the jsfiddle in Safari you can click and scroll across the top, even though no scrollbar shows.
jsfiddle
.testOne {
transform: rotateX(180deg);
overflow-x: scroll;
scrollbar-color: #ffde00 #f7f7f7;
}
.testOne::-webkit-scrollbar {
height: 20px;
}
.testOne::-webkit-scrollbar-thumb {
background-color: #ffde00;
}
.testTwo {
transform: rotateX(180deg);
width: 100%;
display: flex;
visibility: visible;
}
.item {
padding-right: 10px;
list-style: none;
}
<ul class="testContainer">
<span class="testOne">
<span class="testTwo">
<li class="item">
<img src='http://dummyimage.com/255x255/f0f0f0/000000' alt='' title=''/>
</li>
<li class="item">
<img src='http://dummyimage.com/255x255/f0f0f0/000000' alt='' title=''/>
</li>
<li class="item">
<img src='http://dummyimage.com/255x255/f0f0f0/000000' alt='' title=''/>
</li>
</span>
</span>
</ul>
Hoping someone has run into this and can advise a way to show the scrollbar.
When you have transforms on direct child elements it's having the issue. Try moving the transform up one level to the .testContainer element.
.testContainer {
width: 100%;
display: flex;
flex-direction: row;
margin: 0;
padding: 0;
position: relative;
overflow-x: hidden;
transform: rotateX(180deg);
}
.testOne {
overflow-x: scroll;
}
.testOne::-webkit-scrollbar {
height: 20px;
}
.testOne::-webkit-scrollbar-thumb {
background-color: #ffde00;
}
.testTwo {
transform: rotateX(180deg);
width: 100%;
display: flex;
visibility: visible;
}
.item {
padding-right: 10px;
list-style: none;
}
<ul class="testContainer">
<span class="testOne">
<span class="testTwo">
<li class="item">
<img src='http://dummyimage.com/255x255/f0f0f0/000000' alt='' title=''/>
</li>
<li class="item">
<img src='http://dummyimage.com/255x255/f0f0f0/000000' alt='' title=''/>
</li>
<li class="item">
<img src='http://dummyimage.com/255x255/f0f0f0/000000' alt='' title=''/>
</li>
</span>
</span>
</ul>
I'm quite new in web development. I encoutered a problem which is present only in the Internet Explorer - the CSS style of Main Menu is applied after refresh(just F5, not CTRL-F5). I used MVC .NET to make backend of site. I have no idea how to solve this problem.
The web site with this problem is:
http://jakubkowalczykart.com/
Thank you in advance.
#Edit: Cope snippet which reproduces problem. While opening in Chrome or Firefox it looks good, but in IE it doesn't
Style:
.main_menu {
min-height: 40px;
z-index: 10;
height: 8vh;
position: fixed;
top: 0;
width: 100%;
opacity: 0.90;
background: black;
}
.menu_image {
height:100%;
}
.menu_list {
margin: 0 auto;
height: 70%;
list-style-type: none;
overflow: hidden;
}
.menu_container {
display: flex;
align-items: center;
height: 100%;
}
.menu_list {
margin-right: 3vw ;
height: 70%;
list-style-type: none;
overflow: hidden;
}
.menu_list li {
height: 100%;
float: left;
}
Html:
<html>
<head>
</head>
<body id="body">
<div class="main_menu" id="main_menu">
<div class="logo">
<div id="logo_img" ></div>
</div>
<div class="menu_container">
<ul class="menu_list">
<li>
<a href="#">
<img id="first_menu" class="menu_image" src="http://jakubkowalczykart.com/Content/Images/smallportfoliobutton.png" />
</a>
</li>
<li>
<a href="#">
<img id="second_menu" class="menu_image" src="http://jakubkowalczykart.com/Content/Images/smallshopbutton.png" />
</a>
</li>
<li>
<a href="#">
<img id="third_menu" class="menu_image" src="http://jakubkowalczykart.com/Content/Images/smallaboutbutton.png" />
</a>
</li>
<li>
<a href="#">
<img id="fourth_menu" class="menu_image" src="http://jakubkowalczykart.com/Content/Images/smallcontactbutton.png" />
</a>
</li>
</ul>
</div>
<div class="main_container" id="main_container">
</div>
<div class="footer">
</div>
</body>
</html>
I am creating a div that contains an image with text that overlays a large photo following these directions - How to position text over an image in css .
However, once I've done that the div below bleeds into this div with the image. What am I doing wrong.
HTML:
<div class="header-container">
<header class="wrapper clearfix">
<h1 class="title"><img src="img/ptmn_logo.gif" alt=""></h1>
<nav>
<ul>
<li>On Stage</li>
<li>Support</li>
<li>About</li>
<li>Contact</li>
</ul>
</nav>
</header>
</div>
<div class="main-container">
<div id="bg">
<img src="img/header.jpg" alt="">
<p>This is your theater.</p>
</div>
<div class="main wrapper clearfix">
And the CSS:
#bg {
position: relative;
top: -50%;
width: 200%;
height: 200%;
z-index: -1;
}
#bg img {
position: absolute;
display: block;
top: 0;
left: 0;
margin: auto;
min-width: 50%;
min-height: 50%;
z-index: 0;
}
#bg p {
position: absolute;
z-index: 100
}
.main {
position: relative;
}
I appreciate the help!
Looks like this is all you need. I'd get rid of all of those other styles, especially any margins. You can change the top and left properties of the p element to adjust its position over the header.jpg image.
img {
position: relative;
}
p {
position: absolute;
top: 0;
left: 0;
}
<header>
<img src="img/ptmn_logo.gif" alt="" />
<nav>
<ul>
<li>On Stage</li>
<li>Support</li>
<li>About</li>
<li>Contact</li>
</ul>
</nav>
</header>
<img src="img/header.jpg" alt="">
<p>This is your theater.</p>
Please help me to solve my problem.
I need to make head menu with pictures.
Now i have:
What i need to do:
My HTML code here:
<div id="head">
<div class="site_info">
<div id="tabs">
<ul id="tabMenu">
<li class="dropdown">
<div><a class="tab1">поиск по производителю</a></div>
</li>
<li class="dropdown">
<div><a class="tab2">поиск по назначению</a></div>
</li>
<li class="dropdown">
<div>
<span id="more_search"></span>
<a class="tab4" href="/emarket/cart/">покупки</a>
</div>
</li>
<li class="dropdown">
<div><a class="tab3">сравнение</a></div>
</li>
<li class="dropdown">
<div><a class="tab3">кабинет</a></div>
</li>
</ul>
</div>
</div>
<div class="work" umi:element-id="40">
<div umi:field-name="order_info_top"></div>
</div>
</div>
CSS:
#main #head div.site_info {
padding-top: 45px;
}
#main #head div.site_info ul {
width: 50%;
margin: 0 auto;
min-width: 1024px;
}
#main #head div.site_info ul li {
display: inline;
margin-right: 18px;
}
#main #head div.site_info ul li a.tab1 a.tab2 a.tab3 a.tab4 {
float: left;
margin-left: 89px;
}
Give a height and width to the individual menu. Then add a style with your image as its background. Position the backgruond image top center.
HTML
<div>
<ul>
<li class="dropdown"><div><a class="tab1">Menu 1</a></div></li>
<li class="dropdown"><div><a class="tab2">Menu 2</a></div></li>
</li>
</ul>
</div>
CSS
li
{
list-style: none;
float: left;
width :100px;
}
.dropdown .tab1
{
background : url('http://www.indievisionmusic.com/wp-content/themes/indievisionmusic/images/at_symbol_10x10.gif') no-repeat top center;
padding-top: 10px;
}
.dropdown .tab2
{
background : url('http://www.gigabyte.us/images/icon_blue.png') no-repeat top center;
padding-top: 10px;
}
DEMO
Just change your text for <img src="images/image.jpg">
And if you want it to be a link: <img src="images/image.jpg" width="100" height="100"/>
you could just use images instead of text and add in the image using the CSS backgroundd feature
li a.tab1 { background: url(); width:XXpx; height: XXpx }
li a.tab2 { background: url(); width:XXpx; height: XXpx }
li a.tab3 { background: url(); width:XXpx; height: XXpx }
I want to create a drop down menu view based on the following HTML / CSS :
<!DOCTYPE html>
<html>
<head>
<style>
html * {
margin: 0;
padding: 0;
}
body {
color: #FFF;
}
#panel, #content {
position: absolute;
top: 0;
bottom: 0;
}
#panel {
left: 0;
width: 750px;
background: #333;
z-index: 100;
padding-top: 200px;
padding-left: 250px;
}
#content {
background: #000;
left: 250px;
right: 0px;
}
#panel > nav {
margin-bottom: 100px;
}
.Dropdown {
position: relative; /* Has to be set, can be overriden */
}
.Dropdown > ul {
position: absolute;
display: none;
list-style-type: none;
}
.Dropdown:hover > ul {
display: block;
}
.Dropdown > ul, /* On the right by default */
.Dropdown.Right > ul { /* Deploys on the right side of the label */
top: 0;
left: 100%;
}
.Dropdown.Bottom > ul { /* Deploys below the label */
top: 100%;
left: 0;
}
</style>
</head>
<body>
<div id="panel">
<nav class="Dropdown Right" style="width: 200px;"><!-- so it can appear on jsfiddle -->
<div class="Label Parent">Label</div>
<ul>
<li>
<div class="Label">Entry</div>
</li>
<li>
<div class="Label">Entry</div>
</li>
<li>
<div class="Label">Entry</div>
</li>
<li>
<nav class="Dropdown Right">
<div class="Label Parent">Label</div>
<ul>
<li>
<div class="Label">Entry</div>
</li>
<li>
<nav class="Dropdown Right">
<div class="Label Parent">Label</div>
<ul>
<li>
<div class="Label">Entry</div>
</li>
<li>
<div class="Label">Entry</div>
</li>
<li>
<div class="Label">Entry</div>
</li>
<li>
<div class="Label">Entry</div>
</li>
</ul>
</nav>
</li>
<li>
<div class="Label">Entry</div>
</li>
<li>
<div class="Label">Entry</div>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</div>
<div id="content">
</div>
</body>
I would like a developper to be able to extend this drop down CSS to add, for example, a transition between 0 and 1 opacity.
Actually it is not possible with this code because the property display conflicts with the transition one. Adding opacity 0 on the non-hover and opacity 1 on the hover will not work because of that display property.
I've read somewhere on this web site that i could use height 0 and height auto instead of display none and display block (respectivly) but it didn't work either.
Any ideas about how to add transitions please ?
Thanks for your help !