相关疑难解决方法(0)

使图像位于文本后面并使用css将其保持在中心位置

我正在创建一个网页,我有一个图像,我想放在中心,然后在该图像的顶部,我想有输入框和标签和提交按钮.

我正在尝试使用CSS

img.center
{
    z-index:-1;
}
Run Code Online (Sandbox Code Playgroud)

但这不起作用.当我将代码更改为

img.center
{
    position:absolute;
    left:0px;
    top:0px;
    z-index:-1;
}
Run Code Online (Sandbox Code Playgroud)

如果使图像落后,但随后我使用left:0pxtop:0px...它将图像放在0,0 ..但我希望图像保持在中心.

保持图像在中心我有<div align="center">标签.

无论如何,我可以将图像保持在中心并使其落后吗?

我的.html页面看起来像这样:(我确实为我的div标签设置了一个背景图片,但那里没有出现图像)

<html>
<head>
<title>Question of the Week</title>
<style type="text/css">
    body
    {
        background-image:url('images/background.jpg');
        background-repeat:repeat-x;
    }

    .container
    {
    background-image:url('images/center.jpg');
    background-repeat:no-repeat;
    }
    td.cntr {padding-top:50px;}
</style>
</head>
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">

    <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>
            <table width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td><div align="left"><img src="images/logo.jpg"></div></td>
                    <td></td>
                    <td><div align="right"><img src="images/right_logo.jpg"></div></td></tr>
            </table>
        </tr>
        <tr>
            <table width="100%" border="0" …
Run Code Online (Sandbox Code Playgroud)

html css

15
推荐指数
3
解决办法
22万
查看次数

标签 统计

css ×1

html ×1