Home > Web Front-end > HTML Tutorial > CSS+DIV布局_html/css_WEB-ITnose

CSS+DIV布局_html/css_WEB-ITnose

WBOY
Release: 2016-06-21 09:34:43
Original
918 people have browsed it

#Layer1 {	position:absolute;	width:98%;	height:1091px;	z-index:1;	left: 35px;	top: 10px;}
Copy after login
想用CSS控制层宽度为整个浏览器宽度的98%,这样好像不能实现。各位有什么方法吗


回复讨论(解决方案)

你的意思是浏览器clientWidth减去滚动条宽度的98%?

<!doctype html><html><head><meta charset="utf-8" /><title>宽度百分比</title><style type="text/css">*{	margin:0;	padding:0;}#Layer1 {    position:absolute;    width:98%;    height:1091px;    z-index:1;    left: 35px;    top: 10px;	background:blue;}</style></head><div id="Layer1"></div><body></body></html>
Copy after login

为什么要用绝对路径呢?


body{margin:0 auto;}
#Layer1{width:98%; margin:0 auto;}

楼主把你发现问题的demo整理下贴出来。

楼主把你发现问题的demo整理下贴出来。 不好意思,可能我弄错了一个id.按照一楼的代码可能实现宽度占整个屏幕的98%,只是不能居中显示。也就是说,右边出现了2%的空白

<!doctype html><html><head><meta charset="gbk" /><title>宽度百分比</title><style type="text/css">*{    margin:0;    padding:0;}#Layer1 {	margin:0 auto;    width:98%;    height:1091px;    background:blue;}</style></head><div id="Layer1"></div><body></body></html>
Copy after login


这个意思?

HTML code

nbsp;html>



宽度百分比
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template