我想创建一个 <div>
其中有一个以大写字母显示的标签/标题。 <div>
是250px
宽。
在<div>
里面, 我会再放一个 <div>
它将包含控件。此内<div>
应该是 center
对齐和外部 <div>
应自动增加其高度以适应控件高度。
外层<div>
和内部<div>
应该有边框。
这可以用 CSS 实现吗?
最佳答案
我不确定你在问什么,但也许这会有所帮助?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>example</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
div#wrapper { display:block; width:250px; height:auto; margin:auto; padding:0; border:1px solid #F00; }
div#wrapper h1 { text-transform:uppercase; text-align:center; }
div#controls { display:block; width:100%; height:100px; margin:0; padding:0; border:1px solid #000; text-align:center; }
div#controls a { display:inline; margin:0 5px; line-height:100px; }
</style>
</head>
<body>
<div id="wrapper">
<h1>header</h1>
<div id="controls">
<a href="#">control</a>
<a href="#">control</a>
<a href="#">control</a>
</div>
</div>
</body>
</html>
关于html - 带标题的 Div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1973209/