Reza Aria
Reza Aria

Reputation: 157

Position fixed with 100% height

I want use 100% height for MAIN id but when I put it 100% height to main id, creativity class is placed on the main. when use pixel for main in different device its look different.

is there any solution to fix it ?

#main {
	width: 100%;
	height: 675px;
}

.main {
	position: fixed;
	width: 100%;
	height: 100%;
	background: url(/images/logo/logo.svg) center no-repeat #ffcc00;
}

.introduction {
	position: relative;
	display: inline-block;
	z-index: 2;
	width: 100%;
	height: auto;
	background: #fcd803;
	text-align: center;
	padding-bottom: 40px;
}

.introduction h1 {
	text-align: center;
	text-transform: uppercase;
	font-size: 24px;
	padding-top: 40px;
}

.introduction span img {
	width: 200px;
	padding-top: 30px;
}

.introduction div {
	text-align: center;
	margin-left: 30px;
	margin-right: 30px;
	margin-top: 30px;
	font-size: 15px;
	line-height: 21px;
}

.creativity {
	position: relative;
	z-index: 2;
	width: 100%;
	height: 320px;
	background: #fcd803;
}

.creativity-img {
	display: block;
	background: url('/images/ariadesk.png');
	background-repeat:no-repeat;
	background-size:contain;
	background-position:bottom;
	width: 100%;
	height: 320px;
	position: absolute;
}

.creativity-img div {
	position: relative;
	text-align: center;
	padding-top: 145px;
}

.creativity-img div h1 {
	font-size: 20px;
	font-weight: normal;
	text-transform: capitalize;
	color: white;
	border: solid 2px #fff; 
	display: inline-block;
	padding: 10px 50px; 
}
<div id="main">
<div class="main">
	<div class="logo"><h1>HUR</h1><br><span>studio</span></div>
	<div class="nav">
		<ul>
			<a href="#introduction"><li>introduction</li></a>
			<a href="#ourwork"><li>work</li></a>
			<a href="#chooseus"><li>service</li></a>
			<a href="#client"><li>client</li></a>				
			<a href="#aboutus"><li>team</li></a>
			<a href="#contactus"><li>contact</li></a>
		</ul>
	</div>
</div>
</div>
<div class="introduction" id="introduction">
	<h1>introduction</h1>
	<span>
        <img src="/images/icon/intro.svg" alt="">
	</span>
	<div><p>
		We are small team of super nerds and talented creatives. Create cutting-edge interfaces and visually stunnig media.<br>
		Experts in providing innovative Web Design, Graphic Design, Digital Imaging, Advertising and Branding service</p>
	</div>
</div>
<div class="creativity">
	<div class="creativity-img"></div>
</div>

Upvotes: 2

Views: 174

Answers (2)

Sherly Febrianti
Sherly Febrianti

Reputation: 1157

I think it is because of your position

your #main is in the same level with .creativity

if you want the .main always on the top, just change your .creativity with z-index: 1   AND   your .main with z-index: 2

You never set the .main index, and it always on the bottom layer.

Is it that case you want to?

Upvotes: 0

haim770
haim770

Reputation: 49123

If you don't mind IE 8 and below, you can use vh (viewport-height) units:

#main {
    width: 100%;
    height: 100vh;
}

Fiddle

Upvotes: 1

Related Questions