源码网,源码论坛,源码之家,商业源码,游戏源码下载,discuz插件,棋牌源码下载,精品源码论坛

 找回密码
 立即注册
查看: 700|回复: 19

[CSS/HTML] 自定义容器和字体大小

[复制链接]

7万

主题

861

回帖

32万

积分

论坛元老

Rank: 8Rank: 8

积分
329525
发表于 2006-6-26 00:00:00 | 显示全部楼层 |阅读模式

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

 


<head>

<title>Home</title>

<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="author" content="The Man in Blue" />
<meta name="robots" content="all" />
<meta name="MSSmartTagsPreventParsing" content="true" />
<meta name="description" content="" />
<meta name="keywords" content="" />

<style type="text/css" media="all">

 


body
{
 margin: 1em;
 text-align: center;
 font-family: Arial, Helvetica, sans-serif;
}

body *
{
 margin: 0;
}

#content
{
 padding: 1em;
 background-color: #BBDDFF;
 background-image: url(column_bg.gif);
 background-repeat: repeat-y;
 background-position: 30em 0;
 text-align: left;
}

#content p
{
 margin-bottom: 1em;
}

#footer
{
 margin-top: 1em;
 padding: 1em;
 background-color: #0066CC;
 text-align: left;
}

#footer a
{
 color: #FFFFFF;
}

#header
{
 margin-bottom: 1em;
 padding: 1em;
 background-color: #0066CC;
 color: #FFFFFF;
 text-align: left;
}

#leftContent
{
 padding-right: 10em;
}

#options
{
 margin-bottom: 1em;
 text-align: right;
}

#options a
{
 color: #000000;
}

#rightContent
{
 float: right;
 width: 8em;
}

#widthContainer
{
 font-size: 0.8em;
 width: 40em;
 margin: auto;
}

.clearer
{
 clear: both;
}

 


</style>

<script type="text/javascript">
<!--

 


function scaleWidth()
{
 var optimalLineLength = "35em";
 var extraAccounting = "12em";
 var minimumTextHeight = "10px";
 var windowWidth = document.body.clientWidth;
 var optimalSize = windowWidth / (parseInt(optimalLineLength) + parseInt(extraAccounting));

 if (optimalSize >= parseInt(minimumTextHeight))
 {
  document.body.style.fontSize = optimalSize + "px";
 }
 else
 {
  document.body.style.fontSize = parseInt(minimumTextHeight) + "px";
 }

 return true;
}

 


function textSize(size)
{
 var theContainer = document.getElementById("widthContainer");
 var increment = 0.1
 var currentSize = parseFloat(document.getElementById("widthContainer").style.fontSize);

 if (!currentSize)
 {
  currentSize = 0.8;
 }

 if (size == "smaller")
 {
  theContainer.style.fontSize = (currentSize - increment) + "em";
 }
 else
 {
  theContainer.style.fontSize = (currentSize + increment) + "em";
 }

 return true;
}

 


-->
</script>

</head>

 


<body onload="scaleWidth();" onresize="scaleWidth();">
 <div id="widthContainer">
  <div id="options">

   <a href="#" onclick="textSize('smaller'); return false;">Text smaller</a> |
   <a href="#" onclick="textSize('bigger'); return false;">Text bigger</a>
  </div>
<!-- END options -->
  <div id="header">
   <h1>Browser-width defined font size</h1>
  </div>
<!-- END header -->

  <div id="content">
   <div id="rightContent">
    <p>
     Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed lobortis ullamcorper augue. Praesent vel felis vitae purus ornare pretium. Nullam porta sollicitudin lectus. Integer non arcu eu neque tincidunt tincidunt. Nullam sapien arcu, ullamcorper sed, hendrerit in, rutrum in, nibh. Aliquam sed enim. Cras rhoncus ullamcorper justo. Aenean quam dolor, consectetuer sed, dapibus quis, iaculis id, diam. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Ut lacinia velit ac elit. Etiam id nulla. Phasellus at arcu ac mauris hendrerit ullamcorper. Quisque posuere sodales risus. Sed nunc nibh, egestas a, blandit eget, facilisis vel, dolor. Cras metus urna, feugiat et, iaculis quis, lacinia a, elit. Etiam enim. Maecenas viverra, est non tincidunt euismod, diam urna volutpat mi, in luctus pede ante sit amet risus.
    </p>
   </div>
<!-- END rightContent -->
   <div id="leftContent">
    <p>
     Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed lobortis ullamcorper augue. Praesent vel felis vitae purus ornare pretium. Nullam porta sollicitudin lectus. Integer non arcu eu neque tincidunt tincidunt. Nullam sapien arcu, ullamcorper sed, hendrerit in, rutrum in, nibh. Aliquam sed enim. Cras rhoncus ullamcorper justo. Aenean quam dolor, consectetuer sed, dapibus quis, iaculis id, diam. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Ut lacinia velit ac elit. Etiam id nulla. Phasellus at arcu ac mauris hendrerit ullamcorper. Quisque posuere sodales risus. Sed nunc nibh, egestas a, blandit eget, facilisis vel, dolor. Cras metus urna, feugiat et, iaculis quis, lacinia a, elit. Etiam enim. Maecenas viverra, est non tincidunt euismod, diam urna volutpat mi, in luctus pede ante sit amet risus.
    </p>

    <p>
     Nulla metus. Ut sodales, tortor nec sollicitudin convallis, diam diam vulputate ligula, lobortis tincidunt urna purus at urna. Pellentesque laoreet. Nulla et dolor. Praesent vestibulum quam convallis neque. Praesent sit amet odio a dui iaculis dignissim. In vel nunc a tellus vulputate pellentesque. Maecenas bibendum. Donec mi nibh, euismod in, iaculis a, eleifend et, enim. In eget lectus vitae pede nonummy elementum. Mauris accumsan, lacus ut euismod varius, odio neque egestas quam, non aliquam velit purus et purus. Vestibulum at elit nec felis suscipit pulvinar. Suspendisse at enim quis lacus mattis condimentum. Proin arcu arcu, imperdiet vitae, aliquam non, congue id, ipsum.
    </p>
    <p>
     Aliquam eu dolor nec risus luctus faucibus. Aenean condimentum, tortor in blandit cursus, dolor magna sagittis orci, vel vehicula dolor ante at lacus. Donec vel felis in enim aliquam molestie. Sed non velit id velit pulvinar consequat. Mauris luctus. Phasellus faucibus turpis nec purus. Mauris eget ante. Donec orci enim, luctus eu, posuere at, luctus quis, pede. In in lectus. Quisque blandit, ipsum eget tincidunt scelerisque, mauris ante accumsan erat, quis congue odio erat vitae diam. Donec ut felis fermentum sem viverra pulvinar. Sed neque lorem, adipiscing ut, placerat a, ornare et, dolor. Vestibulum pretium vehicula nibh. Etiam feugiat, ligula sed pulvinar fringilla, eros arcu placerat urna, nec eleifend nisl leo sit amet urna. Suspendisse quis augue ut nibh venenatis nonummy. Nunc ut augue. In fermentum, neque eget eleifend rutrum, nulla lorem fermentum massa, eu cursus lectus mi id libero.
    </p>
    <p>
     Nam congue ligula quis magna. Vivamus porttitor nunc non dui. Aliquam posuere dapibus tortor. Quisque facilisis, quam in semper luctus, lacus dolor gravida massa, ultrices consectetuer risus arcu nec nibh. Nulla facilisi. In a eros id eros lobortis ultrices. Vivamus sit amet neque eu magna venenatis nonummy. Pellentesque consequat. Etiam ut ipsum. Nulla consectetuer est vel quam.
    </p>
    <p>

     Integer eu diam vitae augue sollicitudin congue. Praesent vulputate pede vel velit. Maecenas dapibus tempus lacus. Quisque lectus metus, pretium ac, mollis nec, dignissim quis, mi. Aliquam purus risus, pharetra eget, condimentum ut, blandit sit amet, leo. Suspendisse iaculis purus sed tellus. Nunc sem justo, porttitor ut, pretium eu, hendrerit eu, nunc. Vivamus sit amet neque in est venenatis faucibus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aliquam rhoncus, eros id ultrices facilisis, pede ligula dignissim eros, sit amet tempus risus urna sed nibh. Sed massa eros, dapibus tristique, blandit et, molestie sed, enim. Phasellus leo. Integer vestibulum volutpat enim. Duis pulvinar ligula. Pellentesque luctus velit a justo. Quisque volutpat, diam quis varius commodo, neque elit dictum tortor, quis aliquet felis risus vitae wisi. Aliquam bibendum, elit ut gravida vehicula, orci turpis auctor dolor, nec tristique tortor dolor eget ipsum.
    </p>
   </div>
<!-- END leftContent -->
   <div class="clearer">
   </div>
  </div>
<!-- END content -->
  <div id="footer">
   <a href="http://www.themaninblue.com/writing/perspective/2003/12/22/">Back to the explanation</a>

  </div>
 </div>
<!-- END widthContainer -->
</body>

 


</html>

 

回复

使用道具 举报

0

主题

1万

回帖

0

积分

中级会员

Rank: 3Rank: 3

积分
0
发表于 2022-9-7 01:17:01 | 显示全部楼层
刷刷刷刷刷刷刷刷刷刷刷刷刷刷刷
回复 支持 反对

使用道具 举报

0

主题

1万

回帖

68

积分

注册会员

Rank: 2

积分
68
发表于 2022-12-21 07:45:34 | 显示全部楼层
逛逛看看瞧瞧
回复 支持 反对

使用道具 举报

0

主题

1万

回帖

0

积分

中级会员

Rank: 3Rank: 3

积分
0
发表于 2023-1-6 02:58:53 | 显示全部楼层
我找了挺久终于找到了
回复 支持 反对

使用道具 举报

2

主题

2万

回帖

473

积分

中级会员

Rank: 3Rank: 3

积分
473
发表于 2023-1-27 02:07:12 | 显示全部楼层
感谢楼主分享
回复 支持 反对

使用道具 举报

4

主题

2万

回帖

303

积分

中级会员

Rank: 3Rank: 3

积分
303
发表于 2023-2-4 22:55:36 | 显示全部楼层
看看怎么样再说
回复 支持 反对

使用道具 举报

7

主题

2万

回帖

288

积分

中级会员

Rank: 3Rank: 3

积分
288
发表于 2023-3-3 23:17:47 | 显示全部楼层
问问问企鹅哇哇哇哇哇
回复 支持 反对

使用道具 举报

0

主题

2万

回帖

0

积分

中级会员

Rank: 3Rank: 3

积分
0
发表于 2023-4-11 10:32:21 | 显示全部楼层
iiguuubhuiuihu
回复 支持 反对

使用道具 举报

6

主题

2万

回帖

247

积分

中级会员

Rank: 3Rank: 3

积分
247
发表于 2023-10-27 09:29:13 | 显示全部楼层
天天源码社区论坛
回复 支持 反对

使用道具 举报

0

主题

2万

回帖

186

积分

注册会员

Rank: 2

积分
186
发表于 2023-11-10 21:44:31 | 显示全部楼层
感谢楼主分享
回复 支持 反对

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies

本版积分规则

手机版|小黑屋|网站地图|源码论坛 ( 海外版 )

GMT+8, 2024-11-22 01:14 , Processed in 0.098352 second(s), 26 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表