码迷,mamicode.com
首页 > Web开发 > 详细

CSS的position设置

时间:2016-01-06 18:00:18      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:

CSS的position设置:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Title</title>
<style type="text/css">
    h1{
        /*设置为relative一般是为其他元素作为基础;*/
        position:relative;
        width:100%;
        border-bottom:1px dashed #999999;
    }
    h1 span.date{
        position:absolute;
        bottom:0;
        right:0;
        font-size:.5em;
        background-color:#E9E9E9;
        color:black;
        padding:2px 7px 0 7px;
    }
</style>
</head>
<body>
<h1><span class="date">Nov.10,2016</span>CosmoFarmer Bought By Google</h1>
</body>
</html>

 

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Title</title>
<style type="text/css">
#contentWrapper{
    /*设置为relative一般是为其他元素作为基础;*/
    position:relative;
}
#leftSidebar{
    /*设置为absolute,其他元素都不知道他的存在;*/
    position:absolute;
    left:0;
    top:0;
    width:200px;
}
#rightSidebar{
    position:absolute;
    right:0;
    top:0;
    width:200px;
}
#main{
    /*设置margin可以空出有效的位置留给其他元素;*/
    margin-left:200px;
    margin-right:200px;
}
</style>
</head>
<body>
<div id=‘banner‘>banner</div>
<div id=‘contentWrapper‘>
    <div id=‘main‘>main</div>
    <div id=‘leftSidebar‘>leftSidebar</div>
    <div id=‘rightSidebar‘>rightSidebar</div>
    <div id=‘footer‘>footer</div>
</div>
</body>
</html>

 

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Title</title>
<style type="text/css">
#banner{
    /*设置为fixed位置固定不变*/
    position:fixed;
    left:0;
    top:0;
    width:100%;
}
#sidebar{
    position:fixed;
    left:0;
    top:110px;
    width:175px;
}
#footer{
    position:fixed;
    bottom:0;
    left:0;
    width:100%;
}
#main{
    margin-left:190px;
    margin-top:110px;
}
</style>
</head>
<body>
<div id=‘banner‘>banner</div>
<div id=‘main‘>main
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
</div>
<div id=‘sidebar‘>sidebar</div>
<div id=‘footer‘>footer</div>
</body>
</html>

 

CSS的position设置

标签:

原文地址:http://www.cnblogs.com/stono/p/5106073.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!