在HTML5中如何设置屏幕百分比

html-css07

在HTML5中如何设置屏幕百分比,第1张

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>景安</title>

</head>

<style type="text/css">

.head{width: 1000pxheight: 200pxmargin:0 auto}

.head-a{width: 30%height: 200pxbackground: bluefloat: left}

.head-b{width: 70%height: 200pxbackground: orangefloat: right}

</style>

<body>

<div class="head">

<div class="head-a"></div>

<div class="head-b"></div>

</div>

</body>

</html>

我们可以使用width:30%和width:70%这样的形式来设置百分比

style type="text/css">

body,html{margin:0padding:20pxfont-size:12pxfont-family:Arialfont:12px/1 Tahoma, Arial}

.stepOut{height:20pxborder:1px solid #000background:#eeewidth:200pxoverflow:hiddendisplay:none}

.stepIn{width:50pxbackground:#FF0080border-top:1px

solid #FFB5DAborder-bottom:1px solid

#fffoverflow:hiddencolor:#ffftext-align:centerfont:12px/1.6 arial}

</style>

试试看

你的页面是否有根据浏览器界面大小自动适应的要求,如果没有,建议使用像素来做页面设计,你的页面的问题其实是浏览器适应问题,换个宽屏一下看起来又OK了那种?如果你本身使用的就是像素,那就是设置值过大。想要不改代码一次性解决,可以使用javascript在页面加载完成后对所有元素大小进行重置为75%