html – 如何在span中插入换行符?
发布时间:2020-12-24 16:50:27 所属栏目:资源 来源:网络整理
导读:现在我想在Q1上打破这一行并将此Q1移到摘要旁边.有办法吗?以下是按钮的CSS. span {display: inline-block;font-size: 80%;line-height: normal;width: 100%;line-height: 2rem;border: 1px solid #019ed5;border-radius: 25px;cursor: pointer;} 解决方法
现在我想在Q1上打破这一行并将此Q1移到摘要旁边.有办法吗?以下是按钮的CSS. span { display: inline-block; font-size: 80%; line-height: normal; width: 100%; line-height: 2rem; border: 1px solid #019ed5; border-radius: 25px; cursor: pointer; } 解决方法尝试添加:display: inline-block; 注意:它可能会改变一些行为. 在HTML中: <span>JAN-MAR <br /> Q1 Summary</span> 您也可以使用js,以获得更加动态的方法: <span class="q-span">JAN-MAR Q1 Summary</span> 你可以使用jQuery来做到这一点: $(document).ready(function(){ $(".q_header").each(function(){ // Get content var content = $(this).text(),// get first word first_w = content.match(/([w-]+)/); // replace the first word with first word and break var new_cnt = content.replace(first_w[0],first_w[0] + "</br>"); // add the css to make it inline-block $(this).css("display","inline-block").html(new_cnt); }); }); (编辑:湘西站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |