简体   繁体   English

使用时如何避免开始换行 <div class=> Ajax刷新加载?

[英]How can I avoid starting new line when using <div class=> for ajax refresh loading?

If I wrap with just like below, it automatically goes to next line. 如果像下面这样包装,它将自动转到下一行。
Without , the button comes right next to it, that's what I want. 没有,按钮就在它旁边,这就是我想要的。
But I have to use for ajax reload purpose. 但是我必须使用Ajax重新加载的目的。 How can I solve this? 我该如何解决?

<div class="bookmark" data-communities-id="<%= community.id %>">
    <%= render :partial => "communities/bookmark", :locals => {:community => community} %>
</div>  

Use the display:inline for bookmark class. 使用display:inline作为书签类。

.bookmark{
    display:inline;
}

You're using a div for something you want as inline content, use a span instead. 您将div用于要作为内联内容的内容,请改用span。

<span class="bookmark" data-communities-id="<%= community.id %>">
    <%= render :partial => "communities/bookmark", :locals => {:community => community} %>
</span>  

Div is a block-level element. Div是一个块级元素。 This means that it will act like a block, and not like an inline element. 这意味着它将像块一样,而不是内联元素。

Change display property to display属性更改为

  • inline if you want to change it to an inline level element; inline如果要更改为内联级别元素);
  • inline-block if you want it to be inline, but to act as a block element level. inline-block如果您希望它是内联的,但充当块元素级别。

Demo: http://jsfiddle.net/ 演示: http//jsfiddle.net/

CSS 的CSS

div {
 border: 1px solid red; 
 padding: 10px; 
 background-color: #ccc;
 color: white;
 width: 100px;
}

HTML 的HTML

Display: block (default):<br/><br/>
<div>Frindcode</div>
<div>Bookmark</div>

<br/><br/><br/>

Display: inline:<br/><br/>
<div style="display: inline;">Frindcode</div>
<div style="display: inline;">Bookmark</div>

<br/><br/><br/>

Display: inline-block:<br/><br/>
<div style="display: inline-block;">Frindcode</div>
<div style="display: inline-block;">Bookmark</div>

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

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