如何用不同的html代码设置单行的两个独立部分



我浏览了w3schools.com,在这里搜索,并在网上尝试了几次搜索。我想不通。我有一个设置了样式文本的div框。但我喜欢在同一行覆盖文本后结束的按钮的对齐文本。因此,在框内,文本向左对齐,按钮向右对齐,而不会干扰框内再次向左对齐的下一行文本。此外,每一行文本都有自己的标题弹出窗口,按钮也会弹出自己的标题,但不断被标题弹出窗口所覆盖。

<html>
<head>
</head>
<body>
<div style="color:orange; border-style: solid; height: 500px; width: 20%; margin: left; float: right">
<p title="Available food in your area.">Food: <span id="food">Abundant</span>
<span style="align-self: right"><title="Move to a new area.  Be careful, it costs growth to move."><button type="button" style="color:green" onclick="move()"><b>Move!</b></button></span></p>
<p title="This is your cells membrane type.">Membrane: <span id="membrane">Bubble</span></p>
</div>
</body>
</html>

带有css代码的div框。

<div style="color:orange; border-style: hidden; height: 500px; width: 20%; margin: left; float: right">

这是正文的第一行。它工作正常,并在框内左对齐。它连接了javascript代码,但该代码不是问题所在,所以我不会添加它

<p title="Available food in your area.">Food: <span id="food">Abundant</span>

这是一个按钮。它与正文的第一行有关(如上)。我希望它在文本行的右边,并在框中对齐。它的标题被上面一行代码的标题改写了。

<span style="align-self: right"><title="Move to a new area.  Be careful, it costs growth to move."><button type="button" style="color:green" onclick="move()"><b>Move!</b></button></span></p>

这是正文的第二行。它正确地向左对齐,并且它的标题工作正常。

<p title="This is your cells membrane type.">Membrane: <span id="membrane">Bubble</span></p>

我让Run代码片段开始工作,并展示了方框。点击全屏查看它的外观。不过按钮应该在盒子的右边。

这样?

<html>
<head>
<title>help</title>
<style>
.dowhatnowparent {
color: orange;
border-style: hidden;
height: 500px;
width: 20%;
float: right;
}
.dowhatnowchild {
color: orange;
border-style: hidden;
float: left;
}
</style>
</head>
<body>
<div class="dowhatnowparent">
<div class="dowhatnowchild">
<span id="food" title="Available food in your area.">Food: Abundant</span>
<div style="float: right;">
<button type="button" style="color: green" onclick="move()" title="Move to a new area.  Be careful, it costs growth to move."><b>Move!</b></button>
</div>
<div class="dowhatnowchild">
<span title="This is your cells membrane type." id="membrane">Membrane: Bubble</span>
</div>
</div>
</div>
<script>function move() { alert('ok'); };</script>
</body>

最新更新