Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 段落和文本内部的超链接标记对齐:居中_Css_Image_Hyperlink - Fatal编程技术网

Css 段落和文本内部的超链接标记对齐:居中

Css 段落和文本内部的超链接标记对齐:居中,css,image,hyperlink,Css,Image,Hyperlink,因此,这里的目标是将图像居中放置在div内。Text align:center作用于不在超链接标记内的图像,但一旦它们在超链接标记内,它不会影响它们,只影响文本 我不想使用display:block和marginleft/right auto,因为我们需要使用float将一些图片左右对齐 你知道为什么超链接会阻止文本对齐吗 您还需要添加文本对齐:居中;用于父锚点使图像在锚点链接内居中对齐 <div style="width:400px"> <p style="text-al

因此,这里的目标是将图像居中放置在div内。Text align:center作用于不在超链接标记内的图像,但一旦它们在超链接标记内,它不会影响它们,只影响文本

我不想使用display:block和marginleft/right auto,因为我们需要使用float将一些图片左右对齐

你知道为什么超链接会阻止文本对齐吗

您还需要添加文本对齐:居中;用于父锚点使图像在锚点链接内居中对齐

<div style="width:400px">
  <p style="text-align:center">
    <a>
      <img src"..." />
    </a>
    Some text..
  </p>
</div>
<div style="width:400px">
    <p style="text-align:center;">
        <a style="text-align:center;">
            <img src"..." />
        </a>
        Some text..
    </p>
</div>