- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试为客户制作一个博客文章页面,并在 Jquery 的帮助下使用了一个表格,使其可以无限横向滚动。问题是我希望它在小于 740px 时不横向滚动。当我弄乱 jquery 和调整大小命令时,该表似乎出现故障。我试着打开 td 的包装,但它出现了很多故障。
<script>
$(function(){
$("#page-wrap").wrapInner("<table cellspacing='10px'><tr>");
$(".post").wrap("<td>");
});
</script>
这是被影响的主体。
<div id="page-wrap">
<article class="post">
<img src="assets/images/tumblr_nqvdnry3Du1ttpk3mo1_1280.jpg"><p>This is a caption!</p>
</article>
<article class="post">
<img src="assets/images/tumblr_nqvdktfpUS1ttpk3mo3_1280.jpg"><p>This is a caption!</p>
</article>
<article class="post">
<img src="assets/images/tumblr_nqvdktfpUS1ttpk3mo2_1280.jpg"><p>This is a caption!</p>
</article>
</div>
这是附加到它的CSS
td {
img {
max-height: 74vh;
max-width: 1280px;
}
p {
font-size:14px;
font-family: Gill Sans;
margin-bottom:0;
line-height: 1.04;
}
}
我已经使用 vh 使图像响应并成为窗口的高度。当我达到 740px 时,我希望它切换到向下滚动。有人建议使用 jquery 动态获取页面上所有图像宽度的大小,但我不能让它不换行。
最佳答案
所以我想通了,但现在有另一个问题。这是解决方案。放弃表格并编写脚本来为我修复它。
(function($){
var windowH = $(window).height();
var windowW = $(window).width();
$(window).on('load', function(){
if(windowW >= windowH) {//this is horizontal
var allImgWidth = 0;
$('article img').each(function(){
allImgWidth += $(this).width() + 10 ;//10 is padding
});
$('html, body').width(allImgWidth); //makes page width of all images and padding that I have set elsewhere
$('article img').height(windowH - 150);//this accounts for header height and margin height from top
$('article img').css('margin-left', '10px');
} else {
$('article img').width(windowW);//if window width is not greater than window height, the images are the width of the original window
};
if(windowW >= windowH) {
(function() {
function scrollHorizontally(e) {
e = window.event || e;
var delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail)));
document.documentElement.scrollLeft -= (delta*80); // Multiplied by 80 (increases speed of scroll)
document.body.scrollLeft -= (delta*80); // Multiplied by 80
e.preventDefault();
}
if (window.addEventListener) {
// IE9, Chrome, Safari, Opera
window.addEventListener("mousewheel", scrollHorizontally, false);
// Firefox
window.addEventListener("DOMMouseScroll", scrollHorizontally, false);
} else {
// IE 6/7/8
window.attachEvent("onmousewheel", scrollHorizontally);
}
})();//function scrollHorizontally ends
} else {
};//else ends
});//onload ends
})(jQuery);//fucntion ends
(function($){
$(window).resize(function(){
var windowH = $(window).height();
var windowW = $(window).width();
if(windowW >= windowH) { //horizontal
var allImgWidth = 0;
$('article img').each(function(){
allImgWidth += $(this).width() + 10 ;
});
$('html, body').width(allImgWidth);
$('article img').height(windowH - 150);
$('article img').css('width','auto');//dynamically resizes pics
$('article img').css('margin-left', '10px');
} else { //vertical
$('html, body').scrollLeft=0;
$('html, body').width(windowW);
$('article img').width(windowW);
$('article img').css('height','auto');
$('article img').css('margin-top', '10px');
};
if(windowH >= windowW) {
$(window).on('mousewheel DOMMouseScroll', function(event){
if (event.originalEvent.wheelDelta > 0 || event.originalEvent.detail < 0) {
// scroll up
}
else {
// scroll down
}
});
} else {
$(window).off('mousewheel DOMMouseScroll');
(function() {
function scrollHorizontally(e) {
e = window.event || e;
var delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail)));
document.documentElement.scrollLeft -= (delta*80); // Multiplied by 80 (increases speed of scroll)
document.body.scrollLeft -= (delta*80); // Multiplied by 80
e.preventDefault();
}
if (window.addEventListener) {
// IE9, Chrome, Safari, Opera
window.addEventListener("mousewheel", scrollHorizontally, false);
// Firefox
window.addEventListener("DOMMouseScroll", scrollHorizontally, false);
} else {
// IE 6/7/8
window.attachEvent("onmousewheel", scrollHorizontally);
}
})();//function scrollHorizontally ends
};
});//window resize ends
})(jQuery);//function ends
不过现在,在初始页面加载时,网站的宽度为 40,000 像素。从垂直调整为水平时,它很好并且适合。不确定是什么原因造成的。
关于javascript - 响应式侧滚动博客页面问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33375638/
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 7 年前。 Improve this ques
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我基本上有三个环境用于在我的主站点上工作。我的计算机上有我的本地一个,而我的网络服务器上有开发和实时的。我在本地环境中使用 Wordpress 开发了该站点,并希望通过 svn 使所有内容保持最新。
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 5年前关闭。 Improve thi
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我有 gatsby 博客,在我创建新帖子并构建静态文件后,将它们上传到我的主机上,每个用户都必须在我的博客上进行硬刷新才能看到更改。 上传新版本后如何在下次访问时自动刷新? 最佳答案 这种行为的另一个
我需要博客链接,以及涵盖 GroovyFx 的教程。我试过在谷歌上搜索它,我没有得到任何有用的教程。我需要从上到下全面覆盖 GroovyFx! 提前致谢。 最佳答案 您的意思是您想要全面覆盖的博客条目
我最近更换了计算机,并且不小心删除了所有源(Markdown 文件等)的本地版本。不管我怎么想,这一切都在 Github(我使用 GitHub 页面)中,所以我可以从那里开始。但是,我已经进入 Git
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
标题几乎说明了一切。博客在同一个帐户下。 Asked this question on Quora几乎没有回应。 我正在寻找一个网络应用程序,它可以自动执行该过程。如果那里还没有任何东西,我准备使用
在浏览一些关于 Java 反射和泛型的 Jakov Jenkov 博客时,我发现了以下段落: When runtime inspecting a parameterizable type itself
我进退两难:我已经做了rake deploy我的 Octopress 博客运行良好。文档说我必须再做 3 个步骤: git add . git commit -m 'message' git push
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 9 年前。 Improve this ques
我尝试了几种方法,但似乎无法完成其中的每一部分。我为某人制作了一个 wordpress 博客,她对此很满意,但最近想要更改标题。我把它放宽了,她想要它装箱/居中。基本上,标题包含 Logo 、导航和左
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我已经尝试在我的网络服务器上安装 Ghost.io 有一段时间了。我有一个带有 Centos 6 和 Cpanel 的 VPS。 今天我在 http://www.allaboutghost.com/o
这里我有一个网站,tinywolf.uk,我目前正在使用它。主页是一个独立于 wordpress 的静态网站,但网站的博客部分 http://www.tinywolf.uk/blog将由 wordpr
我是 Django Web 开发的半菜鸟。我已经成功添加了一个文件字段,实际上允许我将图像上传到帖子中(图像显示在帖子列表和帖子详细信息中),但是如果我想在帖子中添加多个图像该怎么办? 我目前正在撰写
我特别想了解 Web 开发和 Windows azure。我认为为个人网站创建一个博客应用程序将是一个很好且简单的项目来实现这一目标。 有谁知道演练/教程可以帮助我走上这条路,或者更好地涵盖这个确切的
我遇到了一个小问题,因为我目前正在尝试以编程方式同时登录两个 wordpress 博客。我有一个自定义登录页面,必须为两个 wordpress 博客创建 session 。一个博客工作得很好,但因为我
我是一名优秀的程序员,十分优秀!