【问题标题】:div with 2 buttons in grailsgrails中有2个按钮的div
【发布时间】:2014-11-12 14:48:18
【问题描述】:

我创建了以下 div 样式的 2 个按钮:

.btn-section{
    display: inline;

}

这是gsp文件中的代码:

<div class="btn-section  feed-meta">
    <g:if test="${currentUser != null}">
        <likeable:button bean="${statusMessage}" user="${currentUser}" source="news" directLink="${directLink}"
                         cssClass=" btn-tertiary"/>
    </g:if>
    <g:if test="${directLink != 'true'}">
        <a href="#" class="comment-toggle btn-tertiary">Comment</a>
    </g:if>
</div>

btn-tertiary 的 css 是:

.btn-tertiary{
    padding:15px 25px 15px 25px;
    background-color:#f2f2f2;
    font-family:"font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif";
    font-weight:400!important;
    font-size:13px!important;
    color: #444!important;
    border:none;
}

我无法将它们以相同的宽度相邻放置。

p.s 按钮的 div 应该是屏幕的宽度

div class="mod activities home">
    <div class="mod head update">
        <a href="/threebaysover/profile?id=Ng%3D%3D" class="avatar-image square">

                <img src="http://331e84836dff4bcefe4c-0b83aa77f26cb44bf666af6296cf13e3.r75.cf2.rackcdn.com/c957b62d-b771-40b0-97a9-f8508b3d6487.jpg" alt="Avatar" onerror="this.src='http://c663375.r75.cf2.rackcdn.com/no-avatar.png'"/>

        </a>


        <span class="profile-tool-tip dotted" url="/threebaysover/profile/profileTooltip/Ng%3D%3D"><a href="/threebaysover/profile?id=Ng%3D%3D" class="title-default">Sarit Rotshild</a></span>




    <span class="text-light">
         </br>

            4 hours ago

    </span>

    </div>

    <div class="mod-body feed feed-238 comment-1"  url="/threebaysover/news/addComment" status="238" data-remove-url="/threebaysover/news/removeComment">


            <p class="max-length">

                vbcbcvbvcbcvcv



            </p>

    <div class="text-small" style="padding-bottom: 15px">
        <div id="postSummery-238">likes <span id="likeNum-238">2</span>
                comments <span id="commentNum-238"> 1</span></div>likes 2comments 1


    </div>
        <div class="btn-section  feed-meta">



                <span id="8-user-238-news"><a   class=" btn-tertiary" onclick="jQuery.ajax({type:'POST',data:{'subjectId': '8','subjectType': 'user','targetId': '238','targetType': 'news','cssClass': ' btn-tertiary','alternateCssClass': 'null'}, url:'/threebaysover/likeable/unlike',success:function(data,textStatus){jQuery('#8-user-238-news').html(data);},error:function(XMLHttpRequest,textStatus,errorThrown){}});completeLike(238,true,false);">Unlike</a></span>

             <a  href="#" class="comment-toggle btn-tertiary" >Comment</a>














            <div class="feed-like">

    <div class="feed-comments">

【问题讨论】:

  • 从您的.gsp 发布生成的html,如果可能的话,创建一个jsfiddle
  • @vcarvalho- 我写了 html.. 它是 .gsp 的一部分
  • 是的,我知道,但我不知道&lt;likeable:button 会生成什么html。在浏览器中打开页面 -> 右键单击​​ -> 显示源代码,然后发布 html。

标签: jquery css grails button


【解决方案1】:

这是一个使用flex 属性(http://www.w3schools.com/cssref/css3_pr_flex.asp)的示例:

.btn-section {
    display: flex;
    width: 100%;
}
.btn-tertiary {
    padding:15px 25px 15px 25px;
    background-color:#f2f2f2;
    font-family:"font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif";
    font-weight:400!important;
    font-size:13px!important;
    color: #444!important;
    border:none;
    -webkit-flex: 1; /* Safari 6.1+ */
    -ms-flex: 1; /* IE 10 */ 
    flex: 1;
    text-align: center;
}
.btn-tertiary-red {
    background-color:red;
}
<div class="btn-section  feed-meta"> 
    <a href="#" class="btn-tertiary">foo</a>  
    <a href="#" class="btn-tertiary btn-tertiary-red">Comment</a>
</div>

【讨论】:

  • @vcarvalho- 出于某种原因对我来说只会造成混乱。一键横一竖
  • @vcarvalho- 问题出在喜欢/不喜欢按钮上。它们是在一个跨度中创建的,这一切都一团糟。我能做什么(我无法将 更改为 )。
  • @SaritRotshild 只需更改 css 来处理跨度:http://jsfiddle.net/vcarvalho/pgpjeLj0/1/
猜你喜欢
  • 2021-09-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-06-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多