javascript - 连续显示两个 Div 列,这样它也可以与 AMP(加速移动页面)一起使用
问题描述
我正在尝试在左侧显示图像(缩略图),在右侧显示一些文本(在 h3 标签中)。
这是我的代码:
CSS
/* Create two equal columns that floats next to each other */
.techrbunrelatedarticlescolumn {
float: left;
width: 50%;
}
/* Clear floats after the columns */
.techrbunrelatedarticlesrow:after {
content: "";
display: table;
clear: both;
}
PHP
<?php while (have_posts()) : the_post(); ?>
<?php if (has_post_thumbnail()):?>
<a href="<?php the_permalink(); ?>" rel="bookmark">
<div class="techrbunrelatedarticlesrow">
<div class="techrbunrelatedarticlescolumn" style="padding-right:10px;">
<img height="200" max-width="300" title="<?php the_title(); ?>" src="<?php the_post_thumbnail_url(); ?>">
</div>
<div class="techrbunrelatedarticlescolumn">
<h3><?php the_title(); ?></h3>
</div>
</div>
</a>
<br/>
<?php endif; ?>
<?php endwhile; ?>
这通常工作得很好。但是,当我激活 amp 插件(删除 AMP 中不允许的所有元素)时,图像开始显示在文本上方,从而破坏了结构。
任何人都可以帮我找出一种在不违反 AMP 限制的情况下工作的方法吗?
解决方案
实际的问题是我不知道你不能在任何你想要的地方声明块。AMP 只允许每页一个样式块。通过将所有 CSS 放在一个块下解决了这个问题!
推荐阅读
- python - 如何在 for 循环中生成具有不同名称的新数组?
- python - 从用户那里获取整数输入来计算 Python 函数
- python - 避免
和 被 Spacy 解析 - mysql - JavaFX 如何在另一个项目中使用我自己的 .jar 库?
- c - 如何修改 BFS 算法以在给定条件下找到 2 个顶点之间的路径?
- vue.js - 添加弹出模式以 vuetify vue.js
- python - Modifying dictionary inside function without return statement
- javascript - 有没有办法检查单元格中的单词?
- python - 为什么我们将对 numpy.random.random 的调用乘以数字并减去数字?
- python - Azure 中与 Aws SqS 最相似的队列服务是什么?