1

我正在创建一个网络,但在对齐 div 时遇到了问题。现在一天都解决不了这个问题。

如何强制对齐图像(文本图像)?它在 div 里面。

<!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" charset="utf-8;" content="text/html" />



<link rel="stylesheet" type="text/css" href="styles.css" />

</head>
<

并在窗口调整大小或放大/缩小时强制下部 div 保持原位。

4

3 回答 3

1

如果您真的想将“文本图像”用作常规图像,为什么不在样式表中使用它呢?所以现在你把它放在一个div中,所以让那个div成为一个类或id,并制作一个样式表,在那里你把那个图像作为背景图像。然后,您可以使用位置策略将图像放置在您想要的任何位置。

HTML:

<body>
      <div class="textimage">

      </div>
</body>


CSS:

.textimage{
width:500px;
height:500px;
background-image: url('..whatever.gif'); 
background-position: 50px 50px; //the first coordinate moves the image left to right // while the second coordinate moves it up and down
}
于 2013-07-08T13:03:45.887 回答
1

试试看

<div style="text-align: center">
    <img style="width: 960px;" src="images/about us img.jpg"></img>
    <div style="text-align: center">
            <img src="images/about-cti.jpg"></img>
            <br />ABOUT CTI
    </div>
</div>
于 2013-07-08T13:10:25.730 回答
0

第一个问题是当您希望调整大小或放大/缩小时,不要添加特定的边距,如“margin-right:300px”。

第二个问题是在图像中添加“float:right”。

以下对代码的更改将解决您的问题。

<div style="width: 960px; margin:0 auto;" align="left">
   <p>
     <span style="float:left">
       <br>
       ABOUT CTI
     </span>
     <img src="images/about-cti.jpg"/>
   </p>
</div>
于 2013-07-08T13:10:24.957 回答