[英]based on window size add <br><br> this tag
Need to add this a break tag at the end of the li tag for a mobile version and hide it for desktop.So wht function to write and what window size to select? 对于移动版本,需要在li标签的末尾添加一个break标签,然后将其隐藏在桌面上。那么要编写函数以及选择哪个窗口大小?
<li class="border_bottom_none" id="userbenifit">
Benefit
<em class="sub_text_heading float_right">
<div id="benefitId"></div>
</em>
</li>
Since i am dynamically calling a function to dispplay benefit it, its content character size may differ. 由于我正在动态调用一个函数以使其受益,因此它的内容字符大小可能会有所不同。 hence for a long description it doesnt get displayed well.
因此,很长的描述它不能很好地显示。 Adding a break tag would solve if i can find the window size and break to display the same
添加中断标签将解决是否可以找到窗口大小并中断以显示相同的窗口
Use jquery window resize 使用jQuery窗口调整大小
$(window).resize(function(){
if($(window).width() < 640){ // take 640 as your breakpoint
$("#userbenifit").append("<br/><br/>");
}else{
// remove br
}
})
or use media-query and add margin-bottom : 或使用media-query并添加margin-bottom :
<li class="border_bottom_none added-class" id="userbenifit">
Benefit
<em class="sub_text_heading float_right">
<div id="benefitId"></div>
</em>
</li>
css: CSS:
@media only screen and (max-width: 640px) {
.added-class{
margin-bottom : 2em;
}
}
I guess something like this might work : 我猜像这样的事情可能会工作:
$(function(){
if($(window).width() < 600) // change this to your breakpoint
{
$("#userbenifit").append("<br/><br/>");
}
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.