[英]Internal Style Sheet basic issue
I am trying to create a basic style sheet with a background, and a form in the middle. 我正在尝试创建一个带背景的基本样式表,并在中间创建一个表单。
With the code I have, the background shows but the form is not visible. 使用我的代码,背景显示但表单不可见。 When all is said and done, the only HTML I will need will be text inside the form. 完成所有操作后,我需要的唯一HTML将是表单内的文本。 But for now, I need the form to display. 但是现在,我需要显示表单。 I am sure it is a mental error on my part, but here is the code: 我确信这是我的心理错误,但这里是代码:
<head>
<title>Basic Form</title>
<style type="text/css">
body
{
background-image:url('images/background.png');
}
#main{
background: url('/images/form.png') 0 0 no-repeat;
margin:250px auto;
z-index: 1;
}
</head>
<body>
<div id="main">
</div>
</body>
</html>
You have not set any dimensions for #main, so the width and height are auto. 您没有为#main设置任何尺寸,因此宽度和高度都是自动的。
That div has no content, so the height becomes 0
. 该div没有内容,因此高度变为0
。
With no height, there is no visible area to render a background image on. 没有高度,没有可见区域来渲染背景图像。
如果你想看到你的div那么你需要在里面放一些东西或给它一个最小高度。
Since the <div>
has no height (width is 100% by default), no background will show. 由于<div>
没有高度(默认宽度为100%),因此不会显示任何背景。 You should simply insert your form or at least set a min-height
on it. 您只需插入表单或至少在其上设置min-height
。
Also, you forgot to close your <style>
tag. 此外,您忘记关闭<style>
标记。
如果它不是拼写错误,那么<style>
标签应该在头部内部关闭。
Basic Form 基本表格
body
{
background-image:url('images/background.png');
}
#main{
background: url('/images/form.png') 0 0 no-repeat;
margin:250px auto;
z-index: 1;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.