简体   繁体   English

在底部放置两个div块

[英]Placing two div blocks at bottom

What I am trying to do is, placing the two div blocks, CV and Contact at the bottom of the page, and when hovered over it, they would cover the whole page like they do at this state. 我想要做的是,在页面底部放置两个div块,CV和Contact,当它悬停在它上面时,它们将覆盖整个页面,就像它们在这种状态下一样。 I tried to move them with margin-top property, but they didn't behave proper when i hovered on them. 我试图用margin-top属性移动它们,但是当我在它们上面徘徊时它们表现得不正常。 Also, I want no scroll bars that is whatever user's screen size is, the boxes always appear in corner of page. 此外,我不希望任何用户屏幕尺寸的滚动条,框总是出现在页面的一角。 Is my solution is valid for this, or do i need some javascript to do these? 我的解决方案对此有效,还是我需要一些javascript来执行这些操作? Here is my jsfiddle: 这是我的jsfiddle:

http://jsfiddle.net/cR9NL/ http://jsfiddle.net/cR9NL/

what positions should I use in this situation: absolute or relative ? 我应该在这种情况下使用什么位置: absolute还是relative

Make the lower-left and lower-right divs positioned absolute, with 0 for the bottom value and 0 for the left and right values, respectively. 使左下和右下div成为绝对值,底值为0,左值和右值为0。

Fiddle :) : 小提琴:):

position:absolute;
bottom:0;
right:0;

http://jsfiddle.net/cR9NL/1/ http://jsfiddle.net/cR9NL/1/

html code is still the same, below is my css for you and demo: HTML代码仍然相同,下面是我和你的css演示:

CSS CSS

html, body { height: 100%; max-width: 100%; margin: 0; padding: 0; }

#container {
    position: relative;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

#container div {
    height: 25%;
    width: 15%;
    text-align: center;
}

#container>div:hover {
    height: 100%;
    width: 100%;
    text-align: center;
    position: absolute;
    z-index: 5;
}

#upper-left{
    background: #77cc00;
    float: left;
    border: solid 3px #99ee22;
}


#upper-right{
    background: #ffdd22;
    float: right;
    border: solid 3px #ffff44;
}
#lower-right {
    position: absolute;
    bottom:0;
    right: 0;
    background: #55bbff;
    border: solid 3px #77ddff;
}
#lower-left{
    position: absolute;
    bottom: 0;
    left: 0;
    background: #ff5522;
    border: solid 3px #ff7744;
}
#container>div>p {
    font-family: Tahoma; 
    margin: 28% auto;
    font-weight: 900;
    color: white;
    font-size: 30px;
}

DEMO DEMO

http://jsfiddle.net/bartekbielawa/cR9NL/2/ http://jsfiddle.net/bartekbielawa/cR9NL/2/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM