- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个灵活的 .container
,width:100%
。我想将两个肖像图像(宽度不同)并排放入这个`.container``
<div class="container">
<p>Some Text</p>
<img src="this-is-a-landscape-image.jpg" alt="test"/>
<p> Some Text again</p>
<img class="portait" src="this-is-a-portrait-image.jpg" alt="test"/>
<img class="portrait" src="this-is-a-portrait-image.jpg" alt="test"/>
</div>
我遇到的问题:我正在开发一个响应式布局,其中此 .container
是灵活的 - width:100%
。但是,我希望能够将两个图像(具有 .portrait
类)并排放入此容器中。
正如您在这个示例图像中看到的,两个 .portrait
图像不一定具有相同的宽度?我希望它们的高度相同,但宽度应该是动态的(如果它们的比例不同)
用纯 css(也许是 flexbox)这在某种程度上是可能的吗?还是一点点JS?
内容是通过 CMS 动态填充的,所以这就是我不能对其进行硬编码的原因。
有什么创意或有用的想法吗?
最佳答案
我不认为在纯 css 中有一个完全动态的解决方案(尽管我很想被证明是错误的!)
我在这里写了一个快速的 jQuery 解决方案:http://jsfiddle.net/d2gSK/2/您可以调整图片大小、窗口大小和装订线宽度,两张图片的高度应保持相同,而宽度应按比例设置。
JavaScript 看起来像这样:
// put it in a function so you can easily reuse it elsewhere
function fitImages(img1, img2, gutter) {
// turn your images into jQuery objects (so we can use .width() )
var $img1 = $(img1);
var $img2 = $(img2);
// calculate the aspect ratio to maintain proportions
var ratio1 = $img1.width() / $img1.height();
var ratio2 = $img2.width() / $img2.height();
// get the target width of the two images combined, taking the gutter into account
var targetWidth = $img1.parent().width() - gutter;
// calculate the new width of each image
var width1 = targetWidth / (ratio1+ratio2) * ratio1;
var width2 = targetWidth / (ratio1+ratio2) * ratio2;
// set width, and height in proportion
$img1.width(width1);
$img1.height(width1 / ratio1);
$img2.width(width2);
$img2.height(width2 / ratio2);
// add the gutter
$img1.css('paddingRight', gutter + 'px');
}
//when the DOM is ready
$(document).ready(function() {
// cache the image container
var $wrapper = $('.portrait-wrapper');
// set the image sizes on load
fitImages($wrapper.children().get(0), $wrapper.children().get(1), 20);
// recalculate the image sizes on resize of the window
$(window).resize(function() {
fitImages($wrapper.children().get(0), $wrapper.children().get(1), 20);
});
});
我把解释放在代码里面了。随时询问是否需要我进一步解释。
请注意,我在您的图像周围放置了一个包装器,并为图像提供了一个 display: block
和一个 float:left
,这是完成这项工作所必需的!
关于javascript - CSS 或 Javascript : How to fit two portrait images side by side in a container with fluid width?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14861514/
如果没有 Google Fit 应用程序,是否可以使用 Google Fit API? 我想使用 Google Fit API 来计算步数,但是可以在不安装 Google Fit 应用程序的情况下完成
我的应用程序中实现的代码曾经有效,数据已正确插入/显示在 Google Fit 中,但现在不起作用。 我还测试了 BasicHistoryApi 但它不起作用。( https://github.com
我正在努力显示与 Google Fit 应用程序相同的 Activity 历史记录。我在 session 方面做得很好,但我无法正确掌握自动记录的 Activity 。就像示例中的这两个顶级行走一样。
我在使用 Google Fit Api 获取行进距离时遇到问题。我对计步器使用了类似的方法并且有效。它只是说听众已注册。 大部分代码来自 Github 示例。 有什么问题吗? public class
我正在使用此代码尝试检索过去 14 小时内执行的步骤。 YApp myApp = (mYApp) ctx; mGoogleApiClient = myApp.getMyUser();
使用 google fit api 时是否有配额和请求限制?我想使用 google fit api,我很好奇使用它时是否有限制。 最佳答案 您可以在 Google Developer Console
使用 google fit api 时是否有配额和请求限制?我想使用 google fit api,我很好奇使用它时是否有限制。 最佳答案 您可以在 Google Developer Console
无论是使用 fit$loadings 还是使用 fit$Vaccounted 检查它们,我都得到不同的方差值,这些值由因子分析中的因子解释。我正在使用带有 fa() 函数的 psych 包。如果它们应
如果我进入 google api Playground,我会执行以下步骤: 第 1 步:选择并授权 API。我选择两个范围 https://www.googleapis.com/auth/fitnes
我正在执行 https://developers.google.com/fit/android/get-started 中提到的步骤实现一个简单的健身 Android 应用程序。 但是当我想这样做的时
在过去的 6 个月里,我一直在将我的体重输入 Google Fit,现在我想把我的数据拿出来。 访问 Google Fit REST API 不是问题。然而,在所有可访问的数据中找到我的体重数据让我很
我最近尝试尝试使用 Google Fit 应用程序并尝试了 Google Fit developer site 中给出的步骤.并使用了 Android 示例中给出的代码 BasicSensorApi在
我正在创建可以使用 google fit api 的应用程序。 我想获得 google fit 中可用的所有事件( Action )。这里是 google fit 中的事件列表 Reference 。
我尝试了随机森林回归。 代码如下。 import numpy as np from sklearn.preprocessing import StandardScaler from sklearn.m
Google Play documentation claims this is an API_NOT_CONNECTED code ,但是为了访问 Google Fit API,我已经完成了我(认为
我正在使用google javascript api 。为了获取卡路里,我正在使用下一个数据源: 派生:com.google.calories.expished:com.google.android.
我开发了一个需要显示每日步数的应用程序。为此,我使用了 Google Fit SDK 中提供的 API。 似乎一切正常,但我得到的步数与 Google Fit 官方应用程序中显示的步数不匹配。 例如,
我正在尝试从 google fit API 检索用户的每周步数数据,但我从官方 google fit App 数据中获得了不同的步数结果。例如:星期四通过 google fit api 检索到的步数是
我们已经在我们的用户群中发现,自上次 google fit 应用程序更新以来,数据急剧下降,自开始以来,我们一直试图找出代码中的问题。给出时间,我们认为我们使用的版本(当时是 18.0)是问题所在。
拟合高斯混合模型(X-Y数据集)后,如何获取每个分布的参数?例如每个分布的均值、标准差、权重和角度? 我想我可以找到代码 here : def make_ellipses(gmm, ax):
我是一名优秀的程序员,十分优秀!