- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
让我先说我很抱歉发了这么长的帖子。我正在尝试使用 bootstrap carousel,不幸的是我得到的图片并不统一。例如,有些是 100x200,DOE 是 150x100 等。纵横比不同,字母与横向。我尝试了很多事情,包括在 Carousel 中加载我的每张图片时使用以下辅助函数:
function ScaleImage(srcwidth, srcheight, targetwidth, targetheight, fLetterBox) {
var result = { width: 0, height: 0, fScaleToTargetWidth: true };
if ((srcwidth <= 0) || (srcheight <= 0) || (targetwidth <= 0) || (targetheight <= 0)) {
return result;
}
// scale to the target width
var scaleX1 = targetwidth;
var scaleY1 = (srcheight * targetwidth) / srcwidth;
// scale to the target height
var scaleX2 = (srcwidth * targetheight) / srcheight;
var scaleY2 = targetheight;
// now figure out which one we should use
var fScaleOnWidth = (scaleX2 > targetwidth);
if (fScaleOnWidth) {
fScaleOnWidth = fLetterBox;
}
else {
fScaleOnWidth = !fLetterBox;
}
if (fScaleOnWidth) {
result.width = Math.floor(scaleX1);
result.height = Math.floor(scaleY1);
result.fScaleToTargetWidth = true;
}
else {
result.width = Math.floor(scaleX2);
result.height = Math.floor(scaleY2);
result.fScaleToTargetWidth = false;
}
result.targetleft = Math.floor((targetwidth - result.width) / 2);
result.targettop = Math.floor((targetheight - result.height) / 2);
return result;
}
function OnImageLoad(evt) {
var img = evt.currentTarget;
// what's the size of this image and it's parent
var w = $(img).prop('naturalWidth');
var h = $(img).prop('naturalHeight');
//var tw = $(img).parent().width();
//var th = $(img).parent().height();
var tw = $(img).parent().parent().parent().parent().width();
var th = $(img).parent().parent().parent().parent().height();
// compute the new size and offsets
var result = ScaleImage(w, h, tw, th, true);
// adjust the image coordinates and size
img.width = result.width;
img.height = result.height;
$(img).css("left", result.targetleft);
$(img).css("top", result.targettop);
}
并为轮播的每张图片使用以下内容
<img src="~/Images/Img1_Tall.jpg" alt="Tall" id="firstImage" onload="OnImageLoad(event);" />
对于轮播中的第一张图片,效果很好,但之后的每张图片似乎都只是自然大小并且水平居中,但正好靠在轮播的顶部边框上。
我什至更改了“onload”以传递图像的长度和宽度值,但这也不起作用,在调试中似乎只有第一张图像启动了“onload”事件。
我想要的效果是,如果容器的比例为 3:4,图像的比例为 1:2,则图像会拉伸(stretch)以符合左右边缘,并且会垂直居中并在上方有信箱和下面,但容器不会改变,因此轮播的导航按钮不会移动。如果图像是 2:1,图像将拉伸(stretch)以与顶部和底部水平居中相交,左右两侧有信箱,同样保持导航按钮不变。
任何帮助将不胜感激...包括:
what you are trying to do is crazy
最佳答案
你想做类似http://jsbin.com/zotelasa/1的事情吗? .使用该代码,我可以获得事件元素 w、h 或您在代码中用于运行缩放图像的任何其他变量。由于 parent.parent 代码,它适用于轮播主 div,但您可以设置自己的容器。
关于css - 带有不统一图片的 Twitter Bootstrap 轮播,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22884512/
我在我的应用程序中使用开源 iCarousel 来实现轮播控件。我使用的轮播类型是 iCarouselTypeRotary 并且图像在这种类型中线性排列。但是,我需要图像像所附图像中的旋转木马一样带来
有人看过像这样的 jQuery 3D 轮播教程吗? http://web.enavu.com/demos/3dcarouselwip/ 没有给出来源,但想知道是否有人有关于如何连续圈出 DIV 并调整
我正在开发一种使用相机自动拍摄照片的软件。我希望用户能够设置照片间隔。我希望它看起来和工作起来像某种轮播。 它应该是这样的: 当我滑动(或用鼠标拖动)时,它应该沿给定方向移动: 所选项目应始终位于中间
抱歉问了个愚蠢的问题。我正在寻找带有按钮的旋转木马。我在 Bootply 上找到了这个模板,它完全符合我的要求。我在开发方面还很陌生。 也许有人可以向我解释如何摆脱侧面滚动效果。我知道我必须向 Jav
我正在寻找一个可以处理表单元素的 jQuery 轮播风格插件。 这是我需要做的。 我有三个表单元素:两个常规文本框和一个文本区域。还有两个按钮,上一个和下一个。 单击下一步按钮时,文本框/文本区域会切
我想构建一个包含两个图像轮播的网页,并且我希望能够将图像从一个轮播拖动到另一个。 我已经有了与 jCarouselLite 一起使用的图像轮播:它使用两个 UL 元素来指定轮播的图像。这工作得很好。
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 1
我有这段代码可以从数据库中获取轮播图片或视频 $stmt = $con->prepare("SELECT * FROM `Main`"); $stmt->execut
我需要做这个 slider ,我找到了一些代码并尝试了,但没有一个完全是 LIKE THIS .bloco03 img {
我的任务是制作 3 张图片的轮播/幻灯片,只能在移动设备上使用。在桌面上,这些图像将显示在 3 列中。有没有一种方法可以自动转换,而无需我创建两个不同的模块并根据屏幕尺寸隐藏/显示一个? 最佳答案 你
我需要在卡片轮播上创建这种效果。我使用 Owl Carousel ,我给了元素框阴影。但我坚持制作不同位置元素的效果,例如 3d 或任何名称。 这是我想做的 http://www.awesomescr
我已经盯着这段相同的代码看了大约 4 个小时,并尝试观看一些不同的教程。问题是 slider 加载,有 3 张幻灯片的空间,但它只显示第一张幻灯片。 所有图像加载良好(在浏览器中验证),但轮播不会更改
我的 carouse/slider 有问题,我已经做到了,上一张和下一张图片每边各占 25%,中央图片占 50% 宽度。问题是我能够更改左右图像的背景,但我似乎无法将相同的颜色应用于中间图像。我已经尝
我想一次放 5 张图片作为页面的背景,即一张图片会显示一小段时间(比如每张一秒钟),然后重复它们。 我想知道有没有办法用 CSS 或 JS 来做到这一点? 预先感谢您的帮助! 最佳答案 这也许就是您正
我正在寻找一个支持触摸、可拖动、响应式 jQuery 滚动条/幻灯片/轮播/ slider ,用于显示水平可滚动项目列表(例如, eshop、最近将照片添加到数据库等)。 它看起来类似于苹果应用程序商
我想要夹层画廊的 Bootstrap 轮播。基本上;我正在拉入所有图像,并且我想要单行三张图像轮播。这是我非常讨厌的一段工作代码;我真的很想让它适用于无限数量的图像。 {% if page.d
大家好,我有这段代码,我一直在为我的网站编写代码。我正在尝试实现一个轮播功能,其中一张图片在另一张图片之后滑动。我遇到的问题是图片不会滑动。这是我的代码在欢迎 Controller 的索引页面中的样子
我正在构建一个简单的轮播,一旦用户水平滚动,事件点就会改变事件状态。但是,当我滚动时,jQuery 左侧位置返回值没有改变: li_left = li.position().left; // this
我正在尝试将文本放在轮播 slider 中的图像下方,但现在文本出现在图像上,而不是下方。 它看起来像这样: 但我希望它看起来像这样: 这是我的代码: final CarouselSlider aut
我在使用 boostrap carousel 时遇到 CSS 问题 我只是想让它更高,我已经尝试了几个 css 但没有任何效果。代码是在这个 jsFiddle 中,http://jsfiddle.ne
我是一名优秀的程序员,十分优秀!