简体   繁体   English

如何将文字与上面的图像精确对齐

[英]How do I align text in exact center with image above

I'm trying to align some text (asterisk) in the middle of the image above. 我正在尝试在上方图像的中间对齐一些文本(星号)。

I've set the css to align center, but it looks like it's off to the left a bit. 我已经将css设置为居中对齐,但是看起来有点向左偏移。

How do I align the text in the exact center of the square image above? 如何在上面的正方形图像的确切中心对齐文本?

    <div class="alignright">
    <p>
        <img alt="Sign up Today" height="259" src="http://i.ytimg.com/vi/rb8Y38eilRM/maxresdefault.jpg" width="300" /></p>
<p class="asterisk">
    *Price for a single city. Multi-city, state<br>
    and multi-state packages also available.</p> 
</div>
    <div class="circle">
        <span class="number">1</span>
            </div>
                <h3>
                    Banana</h3>
                <p>
                    A banana is an edible fruit, botanically a berry, produced by several kinds
                    of large herbaceous flowering plants in the genus Musa.</p>
                <p>&nbsp;</p>                
    <div class="circle">
        <span class="number">2</span>
    </div>
        <h3>
            Orange is the colour of saffron, pumpkins and apricots.</h3>
        <p>
            Mobile phones, mobile broadband and home broadband in the Orange Shop. Plus the latest
            news, entertainment, sport and lifestyle content from Orange.</p>
        <p>&nbsp;</p> 
      <div class="circle">
          <span class="number">3</span>
      </div>
          <h3>
              Watermelon</h3>
           <p>
               We here at the National Watermelon Promotion Board have one goal: to increase 
               consumer demand for fresh watermelon through promotion, research</p>

jsfiddle: http://jsfiddle.net/7bzc74qy/37/ jsfiddle: http : //jsfiddle.net/7bzc74qy/37/

It is being aligned to the center; 它与中心对齐; you just have a left margin on your image that isn't on your asterisk. 您只在图像上的左边缘没有星号。

在此处输入图片说明

Add those 49px to the asterisk and you're good to go. 将那些49px添加到星号,就可以了。

.asterisk {
    margin: 20px 0 0 49px;
}

JSFiddle JSFiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM