具有html/css背景的div
我已经发现了一个类似的问题,但它没有点击 这是我的代码,我想有两个背景。我知道如何添加两个背景,但一个背景图像需要在一个特定的地方使用divs完成。我的代码可能有最简单的缺陷。请注意,我是一个新手,正试图从我所知甚少的知识中重新进入web开发领域具有html/css背景的div,css,html,Css,Html,我已经发现了一个类似的问题,但它没有点击 这是我的代码,我想有两个背景。我知道如何添加两个背景,但一个背景图像需要在一个特定的地方使用divs完成。我的代码可能有最简单的缺陷。请注意,我是一个新手,正试图从我所知甚少的知识中重新进入web开发领域 <head> <style type="text/css"> body { <div id="currentpage"> background-
<head>
<style type="text/css">
body {
<div id="currentpage">
background-image: url(bgsource/contactpage.png);
background-repeat: no-repeat;
</div>
}
#currentpage{
position: absolute;
width:auto;
height:auto;
left:424px;
top:134px;
margin-left:0px;
margin-top:0px;
}
</style>
<?php include_once("general.php"); ?>
</head>
身体{
背景图片:url(bgsource/contactpage.png);
背景重复:无重复;
}
#当前页{
位置:绝对位置;
宽度:自动;
高度:自动;
左:424px;
顶部:134px;
左边距:0px;
边际上限:0px;
}
我可能想包括我有一个加载到每个页面的general.php模板,这是否也会影响后台工作?您的html和css不正确。请参阅下面的更正
<style type="text/css">
#currentpage{
position: absolute;
width:auto;
height:auto;
left:424px;
top:134px;
margin-left:0px;
margin-top:0px;
background-image: url(bgsource/contactpage.png);
background-repeat: no-repeat;
}
</style>
#当前页{
位置:绝对位置;
宽度:自动;
高度:自动;
左:424px;
顶部:134px;
左边距:0px;
边际上限:0px;
背景图片:url(bgsource/contactpage.png);
背景重复:无重复;
}
html就是这样做的
<div id="currentpage"></div>
您的html和css不正确。请参阅下面的更正
<style type="text/css">
#currentpage{
position: absolute;
width:auto;
height:auto;
left:424px;
top:134px;
margin-left:0px;
margin-top:0px;
background-image: url(bgsource/contactpage.png);
background-repeat: no-repeat;
}
</style>
#当前页{
位置:绝对位置;
宽度:自动;
高度:自动;
左:424px;
顶部:134px;
左边距:0px;
边际上限:0px;
背景图片:url(bgsource/contactpage.png);
背景重复:无重复;
}
html就是这样做的
<div id="currentpage"></div>
像这样更改代码。因为你不能像你在问题中提到的那样在css中应用html标记
<head>
<style type="text/css">
#currentpage{
position: absolute;
width:auto; /* specify width */
height:auto; /* specify height */
left:424px;
top:134px;
margin-left:0px;
margin-top:0px;
background-image: url(bgsource/contactpage.png);
background-repeat: no-repeat;
}
</style>
</head>
<body>
<div id="currentpage"></div>
</body>
#当前页{
位置:绝对位置;
宽度:自动;/*指定宽度*/
高度:自动;/*指定高度*/
左:424px;
顶部:134px;
左边距:0px;
边际上限:0px;
背景图片:url(bgsource/contactpage.png);
背景重复:无重复;
}
并为显示图像的
div
指定width
和height
。否则您将有一个白色背景。像这样更改代码。因为你不能像你在问题中提到的那样在css中应用html标记
<head>
<style type="text/css">
#currentpage{
position: absolute;
width:auto; /* specify width */
height:auto; /* specify height */
left:424px;
top:134px;
margin-left:0px;
margin-top:0px;
background-image: url(bgsource/contactpage.png);
background-repeat: no-repeat;
}
</style>
</head>
<body>
<div id="currentpage"></div>
</body>
**change your css and html**
<head>
<style type="text/css">
#currentpage{
position: absolute;
width:xx;
height:xx;
left:424px;
top:134px;
margin-left:0px;
margin-top:0px;
background-image: url(bgsource/contactpage.png);
background-repeat: no-repeat;
}
</style>
</head>
<body>
<div id="currentpage"></div>
</body>
#当前页{
位置:绝对位置;
宽度:自动;/*指定宽度*/
高度:自动;/*指定高度*/
左:424px;
顶部:134px;
左边距:0px;
边际上限:0px;
背景图片:url(bgsource/contactpage.png);
背景重复:无重复;
}
并为显示图像的div
指定width
和height
。否则您将有一个白色背景。**更改您的css和html**
**change your css and html**
<head>
<style type="text/css">
#currentpage{
position: absolute;
width:xx;
height:xx;
left:424px;
top:134px;
margin-left:0px;
margin-top:0px;
background-image: url(bgsource/contactpage.png);
background-repeat: no-repeat;
}
</style>
</head>
<body>
<div id="currentpage"></div>
</body>
#当前页{
位置:绝对位置;
宽度:xx;
身高:xx;
左:424px;
顶部:134px;
左边距:0px;
边际上限:0px;
背景图片:url(bgsource/contactpage.png);
背景重复:无重复;
}
**更改您的css和html**
#当前页{
位置:绝对位置;
宽度:xx;
身高:xx;
左:424px;
顶部:134px;
左边距:0px;
边际上限:0px;
背景图片:url(bgsource/contactpage.png);
背景重复:无重复;
}
是。您不能在css页面或css脚本中使用div标记
background-image: url(bgsource/contactpage.png);
background-repeat: no-repeat;
position: absolute;
width:auto;
height:auto;
left:424px;
top:134px;
margin-left:0px;
margin-top:0px;
仅在css页面或脚本标记内使用上述代码,但在css中不允许使用div标记是。您不能在css页面或css脚本内使用div标记
background-image: url(bgsource/contactpage.png);
background-repeat: no-repeat;
position: absolute;
width:auto;
height:auto;
left:424px;
top:134px;
margin-left:0px;
margin-top:0px;
只在css页面或脚本标记内使用上述代码,但在css中不允许使用div标记Yep和@Hax_uu作为解释——在css中,您不放置实际的标记,而是放置“选择器”,这是选择样式应用于哪些dom元素(如div)的方法。现在,如果您将div样式应用于此处,您的html代码是,和@Hax_u作为一种解释——在css中,你没有放置实际的标记,而是放置了“选择器”,这是一种选择应用样式的dom元素(如div)的方法。现在,如果你的apply div样式不适用于这里的html代码,你的css中有一个div标记。你的css中有一个div标记。背景仍然没有显示,只是一个白色的屏幕。我已经花了一个小时来处理这个问题。是的,你应该指定宽度和高度,就像Ran说的那样背景仍然没有显示,只是一个白色的屏幕。我已经搞了好一个小时了。是的,你应该指定宽度和高度,就像Ran Saidoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo