【发布时间】:2015-11-07 17:03:41
【问题描述】:
我为移动版制作了一个页面。我根据标题和屏幕大小做了一个条件。这是条件:
If the Title > 17 characters and screen size < 392px
then do:
.postContent img {
bottom: 65px;
}
else and screen size > 391px
.postContent img {
bottom: 50px;
}
这是图片预览:http://i.imgur.com/59IG7UG.png (抱歉,我需要至少 10 个声望才能发布图片)
第一篇文章应该把图片定位为第二篇文章的图片。
如何结合 PHP 和 JavaScript 来改变 CSS :
<?php if (strlen(trim($post->getTitle())) > 17): ?>
<script type="text/javascript">
//do something
</script>
<?php else: ?>
<script type="text/javascript">
//do something
</script>
<?php endif; ?>
我已阅读:PHP conditions depending on window width (media queries?) 但不知道如何实现。
【问题讨论】:
标签: javascript php css conditional