简体   繁体   English

HTML 当对齐不起作用时,如何从左到右更改对齐?

[英]HTML How to change aligned from left to the right, when aligned not working?

I want the buttons + , count and - to be aligned to the right.我希望按钮+count-向右对齐。 Because the numbers on the right take the same space, and the names on the left have different lengths.因为右边的数字占用相同的空间,而左边的名字有不同的长度。 And I want the buttons to be in the same position, independently of the length of the names on left.我希望按钮位于同一个 position 中,与左侧名称的长度无关。 I added almost everything to the style first div: margin to right, padding to right, aligned to right.我在样式第一个 div 中添加了几乎所有内容:向右边距、向右填充、向右对齐。 And nothing works, the buttons are still in the same position.没有任何作用,按钮仍然在同一个 position 中。

在此处输入图像描述

html: html:

<div>
    <li class="list-group-item d-flex justify-content-between lh-sm">
        <h6 class="my-0" style="size: 10px;">{{ item.name }}</h6>
        <div>
            <a class="fab-button red bg-success" style=" float:right;">
                <div class="plus"></div>
            </a>
            <a style="float:right; size: 20px; padding-right: 2mm; padding-left: 2mm;">
                <strong>{{count}}</strong>
            </a>
            <a class="fab-button red bg-success" style=" float:right;">
                <div class="minus"></div>
            </a>
        </div>
        <span class="text-muted">
            {{ item.price }} zł
        </span>
    </li>
</div>

css: css:

 .fab-button {
    border-radius: 50%;
    display: table;
  }

  .fab-button div {
    background:  rgb(0, 0, 0);
    margin: 11px;
    }

  .fab-button .plus {
    width: 4px;
    height: 4px;
    box-shadow: 0 0 rgb(0, 0, 0), 0 -3px rgb(0, 0, 0), 0 3px rgb(0, 0, 0), -3px 0 rgb(0, 0, 0), 3px 0 rgb(0, 0, 0), 0 -6px rgb(0, 0, 0), 0 6px rgb(0, 0, 0), -6px 0 rgb(0, 0, 0), 6px 0 rgb(0, 0, 0);
  }
  .fab-button .minus {
    width: 4px;
    height: 4px;
    box-shadow: 0 0 rgb(0, 0, 0), -3px 0 rgb(0, 0, 0), 3px 0 rgb(0, 0, 0), -6px 0 rgb(0, 0, 0), 6px 0 rgb(0, 0, 0);
  }

It looks like you are using bootstrap and based value has fixed size you could wrap counter and value with this tag <div class="d-flex justify-content-end">看起来您正在使用bootstrap ,并且基于值具有固定大小,您可以使用此标签<div class="d-flex justify-content-end">包装计数器和值

<li class="list-group-item d-flex justify-content-between lh-sm">
  <h6 class="my-0" style="size: 10px;">ssssadaasdsadsadssadsd</h6>
    <div class="d-flex justify-content-end">
      <div class="mx-2">
        <a class="fab-button red bg-success" style=" float:right;">
          <div class="plus"></div>
        </a>
        <a style="float:right; size: 20px; padding-right: 2mm; padding-left: 2mm;">
        <strong>1</strong>
        </a>
        <a class="fab-button red bg-success" style=" float:right;">
          <div class="minus"></div>
        </a>
      </div>
      <span class="text-muted">
         454545 zł
      </span>
  </div>
</li>

Check out Working example here在此处查看工作示例

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

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