将div从右到左与div右边的位置属性对齐

时间:2019-07-16 10:39:29

标签: html css

我喜欢放置一个div,我声明的位置(此处为left: 20%)位于div的右侧而不是左侧。我已经尝试了几件事,但是一切都失败了。存档该怎么办?

The anchor challenge

对于此图像的前两行,我具有以下CSS代码,但是我无法获得第三行的内容。

<!-- Left orientated with anchor left -->
<div style="position: absolute;
            top: 20%;
            left: 20%;              
            ">
     <span>...</span>
</div>

<!-- Right orientated with anchor left but right to left flow -->      
<div style="position: absolute;
            top: 30%;
            left: 20%;
            direction: rtl;             
            ">
     <span>...</span>
</div>

1 个答案:

答案 0 :(得分:0)

<div id="wrap" style="position: absolute; width: 100%; display: inline-table; border: 1px dashed #aaa;">
        <div style="position: relative;
                    display: table-cell;
                    border-right: 1px solid #aaa;
                    width: 20%;   
                    ">
             <span>1</span>
        </div>

        <div style="position: relative
                    top: 30%;
                    display: table-cell;
                    width: 80%;
                    direction: rtl;             
                    ">      
                <div style="position: relative
                            top: 30%;
                            width: 50%;
                            text-align: left;
                            display: table-cell;
                            float: left;         
                            ">2.1<span> 2.2</span>

                </div>
                <div style="position: relative
                            top: 30%;
                            text-align: left;
                            width: 50%;
                            display: table-cell;
                            float: right;        
                            ">3.1<span> 3.2</span>

                </div>
        </div>