如何在HTML页面的左侧添加一张图片

How to add one picture to the left side of HTML page?

本文关键字:一张 添加 HTML      更新时间:2023-09-26

我想在这个页面的左边添加一张图片,我知道基本的HTML。任何建议吗?以下是不工作?我需要两个集装箱还是有什么问题?

<?
session_start();
$_SESSION['usertmp'];
$_SESSION['emailtmp'];
if(strlen($_SESSION['usertmp'])<1 ||is_null($_SESSION['usertmp']))
{
    $_SESSION['usertmp'] = "";
}
if(strlen($_SESSION['emailtmp'])<1 ||is_null($_SESSION['emailtmp']))
{
    $_SESSION['emailtmp'] = "";
}
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Show Information</title>
<style type="text/css">
html, body {height:100%; margin:0; padding:0;}
#page-background {position:fixed; top:0; left:0; width:100%; height:100%;}
#content {position:relative; z-index:1; padding:10px;}
#
</style>
</head>
<body>
<div id="page-background"><img src="images/main.jpg" width="100%" height="100%" alt="Smile"></div>
<left>
<div class="container" style="width:800px" id="content">
<div class="header"><img src="images/logoo.png" width="177" height="61" longdesc="main.php" />
</left>
<center>
<div class="container" style="width:800px" id="content">
  <div class="header"><img src="images/logoo.png" width="177" height="61" longdesc="main.php" />                                <!-- end .header --></div>
<center>
  <div class="content" style="background-image:url(); height:427px; color: #FFF;vertical-align:middle">
    <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="">
<tr>
<form name="form1" method="post" action="checklogin.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="">
<tr>
<td colspan="3"><strong>Member Login </strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="myusername" type="text" id="myusername"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="mypassword" type="password" id="mypassword"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
</table> 
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="">
<tr>
<form name="form2" method="post" action="signup.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="">
<tr>
<td colspan="3"><p>&nbsp;</p>
  <p><strong> Sign Up Here</strong></p></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="myusername" type="text" id="myusername" value = "<? echo $_SESSION['usertmp'] ?>"></td>
</tr>
<tr>
<td>Enter Password</td>
<td>:</td>
<td><input name="mypassword" type="password" id="mypassword"></td>
</tr>
<tr>
<td>Confirm Password</td>
<td>:</td>
<td><input name="mypassword2" type="password" id="mypassword2"></td>
</tr>
<tr>
<td>Email id</td>
<td>:</td>
<td><input name="myemail" type="text" id="myemail" value = "<? echo $_SESSION['emailtmp'] ?>"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Sign Up"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
  </div>
    </center>
  </center>
</body>
</html>

有很多方法可以实现你想要做的事情。如果可以的话,您应该尝试简化您的标记。如果您希望将登录凭据表保存在中间。这是一种使用3个主要div作为32.98%宽度列的方法。将它们向左浮动,并将第一列用于您想要在左侧的图片。这是用中文写的。当然,图像不能工作,因为它没有访问正确的路径http://jsbin.com/muxac/1/edit

<!doctype html>
<head>
<meta charset="utf-8">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" />
<link rel="stylesheet" href="styles/main.css">
<style>
    .col-1, .col-2, .col-3 {
        width: 32.98%;
        float:left;
    }
</style>
</head>
<body>
<div class="container">
<header class="header">
</header>
<div class="row">
    <div class="col-1">
        <div class="header"><img src="images/logoo.png" width="177" height="61" longdesc="main.php" /></div>
    </div> <!-- End of COLUMN 1 --> 
    <div class="col-2"> <!-- Start of COLUMN 2 -->
        <div class="header"><img src="images/logoo.png" width="177" height="61" longdesc="main.php" />
            <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="">
                <tr>
                    <form name="form1" method="post" action="checklogin.php">
                        <td>
                            <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="">
                                <tr>
                                    <td colspan="3"><strong>Member Login </strong></td>
                                </tr>
                                <tr>
                                    <td width="78">Username</td>
                                    <td width="6">:</td>
                                    <td width="294"><input name="myusername" type="text" id="myusername"></td>
                                </tr>
                                <tr>
                                    <td>Password</td>
                                    <td>:</td>
                                    <td><input name="mypassword" type="password" id="mypassword"></td>
                                </tr>
                                <tr>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                    <td><input type="submit" name="Submit" value="Login"></td>
                                </tr>
                            </table>
                        </td>
                    </form>
                </tr>
            </table>
            <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="">
                <tr>
                    <form name="form2" method="post" action="signup.php">
                        <td>
                            <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="">
                                <tr>
                                    <td colspan="3"><p>&nbsp;</p>
                                        <p><strong> Sign Up Here</strong></p></td>
                                </tr>
                                <tr>
                                    <td width="78">Username</td>
                                    <td width="6">:</td>
                                    <td width="294"><input name="myusername" type="text" id="myusername" value = "<? echo $_SESSION['usertmp'] ?>"></td>
                                </tr>
                                <tr>
                                    <td>Enter Password</td>
                                    <td>:</td>
                                    <td><input name="mypassword" type="password" id="mypassword"></td>
                                </tr>
                                <tr>
                                    <td>Confirm Password</td>
                                    <td>:</td>
                                    <td><input name="mypassword2" type="password" id="mypassword2"></td>
                                </tr>
                                <tr>
                                    <td>Email id</td>
                                    <td>:</td>
                                    <td><input name="myemail" type="text" id="myemail" value = "<? echo $_SESSION['emailtmp'] ?>"></td>
                                </tr>
                                <tr>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                    <td><input type="submit" name="Submit" value="Sign Up"></td>
                                </tr>
                            </table>
                        </td>
                    </form>
                </tr>
            </table>
    </div>  <!-- End of COLUMN 2 --> 
    <div class="col-3"> <!-- COLUMN 3 --> 
        <!-- You can leave this empty if you want -->
    </div>
    <div class="row">
        <div class="footer">
        </div>
    </div>
</div>
</div>

</body>
</html>

可以使用CSS来定位图片。下面是代码(将其插入html标签的style属性中):

position:absolute;left:0px;top:0px/*Here inserte the necesary pixels to position the picture*/

如果你想要的只是标题图像在左上角,在<style>中加入以下内容:.header img {display: inline-block; float: left;}