2016-10-05 3 views
0

У меня нет большого опыта работы с HTML и CSS. У меня возникли проблемы с выравниванием содержимого div. Текст (Oculus Rift, виртуальная реальность нового поколения) должен совпадать с кнопкой прокрутки мыши в правом нижнем углу. Но текст перекрывает div выше (мой липкий заголовок). Я просто не могу заставить его работать. Я разместил сайт over here. Я хочу, чтобы это выглядело как this.Проблемы с выравниванием содержимого Div

HTML:

<!DOCTYPE html> 
<html> 
<head> 
<title>InGadget | D&#233; site voor al uw gadget nieuws!</title> 

<meta name = "keywords" content = "InGadget | D&#233; site voor al uw gadget nieuws!" /> 
<meta name = "description" content = "InGadget is d&#233; site voor alles over gadgets." /> 
<meta name="viewport" content="width=device-width"> 


<link href="main.css" rel="stylesheet" type="text/css"> 
<script src="js/jquery-1.8.3.min.js"></script> 
<script src="js/animatescroll.js"></script> 

<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet"> 

<script src="js/classie.js"></script> 
    <script> 
     function init() { 
      window.addEventListener('scroll', function(e){ 
       var distanceY = window.pageYOffset || document.documentElement.scrollTop, 
        shrinkOn = 100, 
        header = document.querySelector(".navbar"); 
       if (distanceY > shrinkOn) { 
        classie.add(header,"scroll"); 
       } else { 
        if (classie.has(header,"scroll")) { 
         classie.remove(header,"scroll"); 
        } 
       } 
      }); 
     } 
     window.onload = init(); 
</script> 

<script> 
    function logoSwitch() { 
     $('.altLogo').each(function() { 
      $(this).css('top', 
         $('.startLogo').offset().top - $(this).closest('.row').offset().top 
         ); 
     }); 
    }; 

    $(document).scroll(function() {logoSwitch();}); 

    logoSwitch(); 
</script> 

</head> 
<body> 
      <div class="navbar"> 
      <div class="container clearfix"> 
       <a id="logo" href="index.html"></a> 
       <div class="nav"> 
        <a href="index.html">Home</a> 
        <a href="#">Nieuws</a> 
        <a href="#">Forum</a> 
        <a href="#">Things I &#10084;</a> 
        <a href="#">Contact</a> 
       </div> 
      </div> 
     </div> 
    <div class="header"> 
     <div class="header-content"> 
      <h1>Oculus Rift<br> 
       Next-generation Virtual Reality.</h1> 
      <div class="mouse-icon" onclick="$('.section1').animatescroll();" style="cursor:pointer;"> 
       <div class="wheel"></div> 
      </div> 
     </div> 
    </div> 

    <div class="section1"> 
     Placeholder 
    </div> 

</body> 
</html> 

CSS:

/* BASICS */ 
@font-face { 
    font-family: Neusa-SemiBold; 
    src: url(fonts/neusa/Neusa-SemiBold.otf); 
} 

@font-face { 
    font-family: Neusa-ExtraBold; 
    src: url(fonts/neusa/Neusa-ExtraBold.otf); 
} 

* { 
    margin: 0; 
    padding: 0; 
} 

.container { 
    width: 80%; 
    margin: auto; 
} 

.clearfix:after { 
    visibility: hidden; 
    display: block; 
    content: ""; 
    clear: both; 
    height: 0; 
} 

/* NAVBAR */ 
.navbar { 
    width: 100%; 
    height: 150px; 
    position: fixed; 
    z-index: 999; 
    -webkit-transition: height 0.6s; 
    -moz-transition: height 0.6s; 
    -ms-transition: height 0.6s; 
    -o-transition: height 0.6s; 
    transition: height 0.6s; 
} 

#logo { 
    width: 275px; 
    height: 150px; 
    background: transparent url(images/logo.png) no-repeat; 
    background-size: contain; 
    float: left; 
} 

.scroll #logo { 
    background-image: url(images/logo2.png); 
} 

.nav { 
    float: right; 
    right: 0px; 
} 

.nav a { 
    line-height: 75px; 
    padding-left: 20px; 
    font-family: 'Montserrat', sans-serif; 
    font-weight: 700; 
    font-size: 20px; 
    text-decoration: none;  
    color: #ffffff; 
    -webkit-transition: all 0.6s; 
    -moz-transition: all 0.6s; 
    -ms-transition: all 0.6s; 
    -o-transition: all 0.6s; 
    transition: all 0.6s; 
} 

.nav a:hover { 
    text-decoration: underline; 
} 

/* STICKY NAVBAR */ 

.navbar.scroll { 
    background-color: #ffffff; 
    height: 75px; 
} 

.navbar.scroll#logo { 
    width: 140px; 
    height: 140px; 
    background: transparent url(images/logo2.png) left top no-repeat; 
} 

.navbar.scroll .nav a { 
    color: #000000; 
    line-height: 75px; } 

/* SECTIONS */ 
.header { 
    background: 
     linear-gradient(to top right, 
      rgba(255, 65, 54, 0.5), 
      rgba(24, 0, 255, 0.5) 
     ), 
     url(nieuws/VR/images/oculusrift.jpg) fixed; 
    background-size: cover; 
    height: 100vh; 
    width: 100%; 
} 

.header-content { 
    width: 80%; 
    margin: auto; 
} 
.header-content h1 { 
    font-family: 'Neusa-ExtraBold', sans-serif; 
    text-transform: uppercase; 
    font-size: 72px; 
    color: #ffffff; 
    text-align: right; 
} 

.section1 { 
    margin-top: 20px; 
    background-color: #f2f2f2; 
    height: 500px; 
} 

/* MOUSE ICON */ 
.mouse-icon { 
    border: 4px solid #ffffff; 
    border-radius: 32px; 
    height: 50px; 
    width: 30px; 
} 

.mouse-icon .wheel { 
    -webkit-animation-name: scrolling; 
    -webkit-animation-duration: 1s; 
    -webkit-animation-timing-function: linear; 
    -webkit-animation-delay: 0s; 
    -webkit-animation-iteration-count: infinite; 
    -webkit-animation-play-state: running; 
    animation-name: scrolling; 
    animation-duration: 1s; 
    animation-timing-function: linear; 
    animation-delay: 0s; 
    animation-iteration-count: infinite; 
    animation-play-state: running; 
} 

.mouse-icon .wheel { 
    border-radius: 10px; 
    background: #ffffff; 
    width: 6px; 
    height: 10px; 
    top: 4px; 
    margin-left: auto; 
    margin-right: auto; 
    position: relative; 
} 

@-webkit-keyframes scrolling { 
    0% { top:5px; opacity: 0;} 
    30% { top:10px; opacity: 1;} 
    100% { top:25px; opacity: 0;} 
} 

@keyframes scrolling { 
    0% { top:5px; opacity: 0;} 
    30% { top:10px; opacity: 1;} 
    100% { top:25px; opacity: 0;} 
} 
+0

Пожалуйста, не смешно @PraveenKumar –

+0

Ха-ха ... Конечно ... Я до сих пор работает на ваши вещи ... Постараюсь опубликовать ожидание решения , –

+0

Ха-ха-ха .. Я просто шутил. Да, именно так. –

ответ

0

Поместите «заголовок-контент 'div внутри другого div с классом' header-content-c ontainer»и добавить этот CSS:

.header-content-container { 
     position: absolute; 
     bottom: 0; 
     width: 100%; 
} 
+0

Большое спасибо! Это поставило проблему. –

+0

Добро пожаловать! – Pirula

0
.header-content h1{ 
    position: absolute; 
    right: 20px; 
    bottom: 20px; 
} 

.mouse-icon { 
    position: absolute; 
    left: 20px; 
    bottom; 20px; 
} 
+0

Хотя этот фрагмент кода может решить вопрос, [включая объяснение] (http://meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers) действительно помогает улучшить качество вашего сообщения. Помните, что вы отвечаете на вопрос читателей в будущем, и эти люди могут не знать причин вашего предложения кода. – andreas

0

Вы должны расположить h1 и mouseicon абсолютными к нижнему

.mouse-icon { 
    border: 4px solid #ffffff; 
    border-radius: 32px; 
    height: 50px; 
    width: 30px; 
    position: absolute; 
    left: 10px; 
    bottom; 10px; 
} 

.header-content h1 { 
    font-family: 'Neusa-ExtraBold', sans-serif; 
    text-transform: uppercase; 
    font-size: 72px; 
    color: #ffffff; 
    text-align: right; 
    position: absolute; 
    right: 10px; 
    bottom; 10px; 
} 
0
.header { 
    position:relative; 
} 
.header-content { 
    position: absolute; 
    bottom: 0; 
    right: 45px; 
} 

Используйте эти стили вместе с другими стилями CSS. Пожалуйста, дайте мне знать, если у вас есть другие требования.

Смежные вопросы