css - 如何将文本与 css 形状对齐

标签 css

页面在这里:

http://www.satearn.com/node/163

我希望文本与 css 形状完美对齐,就好像它们是子弹一样。

.big_bullets {
  display: inline-block;
  -webkit-box-sizing: content-box;
  -moz-box-sizing: content-box;
  box-sizing: content-box;
  position: relative;
  cursor: pointer;
  top: 0;
  padding: 0 19px;
  border: 3px solid rgb(255,255,255);
  -webkit-border-radius: 50px;
  border-radius: 50px;
  font: normal normal bold 20px/50px Arial, Helvetica, sans-serif;
  color: rgb(255, 255, 255);
  text-align: center;
  text-transform: uppercase;
  -o-text-overflow: clip;
  text-overflow: clip;
  background: #069;
  float:left;  
}

.big_bullets_para {
     float:right;
     clear: both;
     margin-right:50%;
}

HTML 看起来像这样:

    <div class="big_bullets">
    A</div>

<div class="big_bullets_para">
    <p>
        Please use the site's shopping cart and use Paypal or credit card options.</p>
</div>

<p>&nbsp;</p>

<div class="big_bullets">
    A</div>

<div class="big_bullets_para">
    <p>
        Please use the site's shopping cart and use Paypal or credit card options.</p>
</div>

<p>
    &nbsp;</p>

<div class="big_bullets">
    A</div>

<p>
    &nbsp;</p>

<div class="big_bullets_para">
    <p>
        Please use the site's shopping cart and use Paypal or credit card options.</p>
</div>

最佳答案

只需将html结构更改为

<div class="big_bullets_para">
    <div class="big_bullets">A</div>
    <p>Please use the site's shopping cart and use Paypal or credit card options.</p>
</div>

JSFiddle demo here .

如果您希望段落与元素符号点的顶部对齐,请使用

.big_bullets_para p {
    margin: 0;
}

关于css - 如何将文本与 css 形状对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29865082/

相关文章:

javascript - 无法更新函数angularjs内的变量值

javascript - .css() 的 jQuery 问题

html - 表格固定标题和可滚动主体,标题后面的内容有问题

html - 绝对div不继承具有固定高度的相对父级的高度

将鼠标悬停在链接上时,CSS 光标属性无法正常工作

c# - asp.NET 4.0 + CSS 问题 : How to create a give a different effect for the current webpage on the menu?

javascript - 如何将 CSS 应用于 v15 中 React 渲染的数组?

css - 使用 CSS 堆叠所有容器

html - 使用 css 在 html 上自定义边框(检查图像)

CSS 媒体查询根本不起作用