Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.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
Html 文本对齐在同一行上不起作用_Html_Css - Fatal编程技术网

Html 文本对齐在同一行上不起作用

Html 文本对齐在同一行上不起作用,html,css,Html,Css,我是新来的,我对代码不太了解。我想要一个链接在块的左侧,另一个链接在右侧。我正在使用下面的命令。两个都在正确的方向,但有一个在新的方向。我在css中给出了正确的代码,但我认为html代码有一些问题。请让我知道下面的错误 <div class="more"> <span><a href="http://www.fe.com/discuss">See More</a></span> </div

我是新来的,我对代码不太了解。我想要一个链接在块的左侧,另一个链接在右侧。我正在使用下面的命令。两个都在正确的方向,但有一个在新的方向。我在css中给出了正确的代码,但我认为html代码有一些问题。请让我知道下面的错误

       <div class="more">
       <span><a href="http://www.fe.com/discuss">See More</a></span>
       </div>
       <div class="placeadhere">
       <span><a href="http://www.fe.com/posting.php?mode=post&f=16">Place Ad Here</a></span>
       </div>
}

}

图像是


非常感谢你的回答解决了我的问题。。。爱你,爱你

我认为问题在于你的css。你也应该把它贴上去

<div class="more" style="width:auto; float: left;">
       <span><a href="http://www.fedri.com/discuss">See More</a></span>
</div>
<div class="placeadhere" style="width:auto; float: right;">
       <span><a href="http://www.fedri.com/posting.php?mode=post&f=16">Place Ad Here</a></span>
</div>

Div是元素,将占据整个宽度。将div指定为inline,以便它只占用所需的宽度。或者,您可以将div的位置设置为绝对位置,并根据需要将其浮动

.more {
 display: inline;
    float: left;
    font-size: 11px;
    margin: 5px 0 10px;
    text-align: right;
}

.placeadhere {
 display: inline;
    float: right;
    font-size: 11px;
    margin: 5px 0 10px;
    text-align: left;
}

查看工作小提琴-

您可以在工作中看到这一点

我在整个HTML片段周围添加了一个额外的div,看起来应该是这样的

<div class="main">
    <div class="more">
        <span>
            <a href="http://www.fedri.com/discuss">See More</a>
        </span>
    </div>
    <div class="placeadhere">
        <span>
            <a href="http://www.fedri.com/posting.php?mode=post&f=16">Place Ad Here</a>
        </span>
    </div>
</div>

使用此选项可自定义div宽度

<div style="width:somevalue">
        <div class="more">
         <span><a href="http://www.fedri.com/discuss">See More</a></span>
       </div>
       <div class="placeadhere" style="float:right;">
        <span><a href="http://www.fedri.com/posting.php?mode=post&f=16">Place Ad Here</a></span>
       </div>
   </div>

只需添加
float

.more {
font-size:11px;
text-align:right;
margin:5px 0 10px 0; float:right
}

.placeadhere {
font-size:11px;
text-align:left;
margin:5px 0 10px 0; float:left
}​

我还添加了css代码。请检查一下。。谢谢..@user1820652您可以在我的解决方案中找到演示。希望您理解这个概念。cdeez请告诉我代码。。我不知道更多。所以很多答案都是有效的。。。。非常好的朋友非常非常感谢你。。。爱你,爱你…所以很多答案都在起作用。。。。非常好的朋友非常非常感谢你。。。爱你,爱你…所以很多答案都在起作用。。。。非常好的朋友非常非常感谢你。。。爱你和SOF…@user1820652记住,你可以选择对你有帮助的答案,也可以通过勾选来选择最佳答案。。
.more {
font-size:11px;
text-align:right;
margin:5px 0 10px 0;
}
.placeadhere {
font-size:11px;
text-align:left;
margin:5px 0 10px 0;
}
.main .more{float:left;}
.main .placeadhere{float:right;}
<div style="width:somevalue">
        <div class="more">
         <span><a href="http://www.fedri.com/discuss">See More</a></span>
       </div>
       <div class="placeadhere" style="float:right;">
        <span><a href="http://www.fedri.com/posting.php?mode=post&f=16">Place Ad Here</a></span>
       </div>
   </div>
.more {
font-size:11px;
text-align:right;
margin:5px 0 10px 0; float:right
}

.placeadhere {
font-size:11px;
text-align:left;
margin:5px 0 10px 0; float:left
}​