框在文本前面

时间:2015-10-22 18:35:12

标签: html css

所以我对HTML和CSS的新东西很新,我正试着把我的文字放在透明的盒子前面。问题是它落后于它,无论我尝试它留在它后面。我尝试了一个占位符(lorem ipsum的东西或其他什么)并且工作得很好,但是只要一个H1标签放置我的整个文本就会神奇地落在盒子后面。像什么?所以我在我的CSS中添加了h1,它以某种方式改变了我的盒子的比例?什么? 这是代码

<!DOCTYPE html>
<html lang="en">
<head>
<meta name="description" conten="The super cool website from the idiot names kawaiinacho. Seriously why do you even bother this place?" />
<title>Kawaiinacho's super cool website!</title>
<link rel="shortcut icon" href="img/icon.ico">
<link href="main.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div class="topbar"></div>
    <nav class="sidebarleft">
        <ul>
            <li><a href="#"><div>Home</div></a></li>
            <li><a href="#"><div>Placeholder</div></a></li>
            <li><a href="#"><div>Placeholder</div></a></li>
            <li><a href="#"><div>Placeholder</div></a></li>
        </ul>
    </nav>
    <div class="text">
        <p><h1>Lorem ipsum</h1> dolor sit amet, consectetuer adipiscing elit. Nam nibh. Nunc varius facilisis eros. Sed erat. In in velit quis arcu ornare laoreet. Curabitur adipiscing luctus massa. Integer ut purus ac augue commodo commodo. Nunc nec mi eu justo tempor consectetuer. Etiam vitae nisl. In dignissim lacus ut ante. Cras elit lectus, bibendum a, adipiscing vitae, commodo et, dui. Ut tincidunt tortor. Donec nonummy, enim in lacinia pulvinar, velit tellus scelerisque augue, ac posuere libero urna eget neque. Cras ipsum. Vestibulum pretium, lectus nec venenatis volutpat, purus lectus ultrices risus, a condimentum risus mi et quam. Pellentesque auctor fringilla neque. Duis eu massa ut lorem iaculis vestibulum. Maecenas facilisis elit sed justo. Quisque volutpat malesuada velit.</p>
    </div>
</body>
</div>
</html>

和main.css

html {
    min-width: 980px;
}
body {
    background-color:#292929;
    background-size: 100%;
    position: fixed;
    padding: 0px;
    margin: 0px;
}
.topbar {
    width: 1920px;
    height: 35px;
    padding: 0px;
    margin: 20px 0px;
    border: 0px;
    color: #AB0000;
    border-bottom: 1px #000000;
    background-color: #AB0000;
    box-shadow: 5px 0px 2px;
}
.sidebarleft {
    margin: 0px;
    padding: 10px 50px 20px 40px;
    border: 0px;
    width: 250px;
    float: left
}
.sidebarleft li {
    margin: 0px;
    padding: 0px;
    border: 0px;
    list-style: none;
}
.sidebarleft a {
    background: #AB0000;
    border-bottom: 1px solid #000000;
    color: #ffffff;
    display: block;
    margin: 0px;
    padding: 8px 12px;
}
.sidebarleft a:hover {
    background: #292929;
    padding-bottom: 8px;
}
.text {
    padding: 0px;
    margin: 26px;
    border: 0px;
    position: absolute;
    left: 400px;
    background-color: black;
    opacity: 0.6;
}
.text p {
    border: 0px;
    padding: 25px;
    margin: 0px;
    color: white;
    max-width: 800px;
}

网站就在http://kawaiinacho.xyz/ 我尝试了z-index,每个位置都有,切换代码arround。似乎没什么用。我做错了什么?

2 个答案:

答案 0 :(得分:2)

  1. 您在HTML上遇到问题 - h1位于p标记内,必须是:

    <h1>THis is heading</h1>
    <p>This is paragraph</p>
    
  2. 然后尝试使用CSS更改颜色:

    .text {
        color: #fff;
    }
    
  3. </div>代码后删除</body>

答案 1 :(得分:0)

文字不在文字框后面,只是文字与文字颜色相同!添加此CSS,您将清楚地看到文本(并且能够选择/突出显示它):

body {color:white;}