微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

html – 使图像在文本后面,并使用css将其保留在中央

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

我试图使用css

img.center
{
    z-index:-1;
}

但这不行.当我将代码更改为

img.center
{
    position:absolute;
    left:0px;
    top:0px;
    z-index:-1;
}

如果使图像落后,但是,因为我使用左:0px和顶部: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" cellpadding="0" cellspacing="0">
                <tr>
                    <td class="cntr">
                        <div id="container">
                            <input name="Box" type="textBox" />
                            <input name="Box" type="textBox" />
                            <input name="submit" type="submit" />
                        </div>
                    </td>
                </tr>
            </table>
        </tr>
    </table>
</body>
</html>

解决方法

那么把你的图像放在你的网站/容器的后面,并放上你想要的东西.所以说你有:
<div id="container">
   <input name="Box" type="textBox" />
   <input name="Box" type="textBox" />
   <input name="submit" type="submit" />
</div>

这是在你的代码,你的CSS将看起来像:

#container {
    background-image:url(yourimage.jpg);
    background-position:center;
    width:700px;
    height:400px;
}

为了这个工作,你必须将高度和宽度指定为特定的值(即没有%),我可以更具体地帮助你,如果你需要它,但我需要更多的信息.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐