简体   繁体   English

如何将这些ul,li和span放在一行中?

[英]How to position these ul, li, and span in one line?

I need to position the 'previous' on the left side of the li and the 'next' to the right so that they are shown in one line. 我需要将“上一个”放置在li的左侧,将“下一个”放置在右侧,以便将它们显示在一行中。 How can I achieve this? 我该如何实现?

<ul style= 'list-style-type: none;'  class="filter1">
    <li><span class="filtercat1">red</span></li>
    <li><span class="filtercat1">blue</span></li>
    <li><span class="filtercat1">yellow</span></li>
    <li><span class="filtercat1">all</span></li>
</ul>


<span id="filterbutton1">
    <a href="#" id="prev">« Previous</a> 
    <a href="#" id="next">Next »</a>

http://jsfiddle.net/BlacBunny/5tfcuy1w/12/ http://jsfiddle.net/BlacBunny/5tfcuy1w/12/

It's easier if you change the order of the nodes in the document: 如果更改文档中节点的顺序,会更容易:

<a href="#" id="prev" class="align">« Previous</a> 
<ul style= 'list-style-type: none;'  class="filter1 align">
    <li><span class="filtercat1">red</span></li>
    <li><span class="filtercat1">blue</span></li>
    <li><span class="filtercat1">yellow</span></li>
    <li><span class="filtercat1">all</span></li>
</ul>
<a href="#" id="next" class="align">Next »</a>

I added an "align" class to the three blocks and styled it: 我在这三个块中添加了“ align”类并为其设置了样式:

.align {
   float: left;
   display: inline-block;
   margin: 5px;
   padding: 5px;
   min-width: 80px;
   text-align: center;
}

http://jsfiddle.net/b0m3xk6z/ http://jsfiddle.net/b0m3xk6z/

http://jsfiddle.net/5tfcuy1w/13/ http://jsfiddle.net/5tfcuy1w/13/

Added CSS code 添加了CSS代码

.right{ float:right !important; }

Included the class to tag 包含要标记的类

You can try this :- 您可以尝试:-

<ul><li><a href="#"  id="prev">Previous</a></li>
    <li>
<ul style= 'list-style-type: none;'  class="filter1">
        <li><span class="filtercat1">red</span></li>
        <li><span class="filtercat1">blue</span></li>
        <li><span class="filtercat1">yellow</span></li>
        <li><span class="filtercat1">all</span></li>
    </ul>
</li>
<li><a href="#" id="next">Next</a></li>
</ul>

LINK 链接

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

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