问题:
我怎样才能让我的照片不那么夸张?为什么我看不到整个图像?
解释:
我将 Nivo Slider Jquery 插件放在我的网页上,效果很好!问题是当我放入图像时,图像尺寸不正确。图像模糊, slider 未显示整个图像。我查看了 CSS,它看起来不错。这是我的 HTML 代码:
<div class="theme-bar slider-wrapper">
<div id="slider" class="nivoSlider theme-bar">
<a href="#"><img src="images/slide1.jpg" alt="" /></a>
<img src="images/slide2.jpg" alt="" />
<img src="images/slide3.jpg" alt="" />
<img src="images/slide4.jpg" alt="" />
</div>
</div>
这是我的 CSS(我有两个链接到此页面的 CSS 文件 nivo-slider.css 和 bar.css 用于 Nivo Slider 主题)。
nivo-slider.css:
.nivoSlider {
position:relative;
width:100%;
height:auto;
overflow: hidden;
}
.nivoSlider img {
position:absolute;
top:0px;
left:0px;
max-width: none;
}
.nivo-main-image {
display: block !important;
position: relative !important;
width: 100% !important;
}
/* If an image is wrapped in a link */
.nivoSlider a.nivo-imageLink {
position:absolute;
top:0px;
left:0px;
width:100%;
height:100%;
border:0;
padding:0;
margin:0;
z-index:6;
display:none;
}
/* The slices and boxes in the Slider */
.nivo-slice {
display:block;
position:absolute;
z-index:5;
height:100%;
top:0;
}
.nivo-box {
display:block;
position:absolute;
z-index:5;
overflow:hidden;
}
.nivo-box img { display:block; }
/* Caption styles */
.nivo-caption {
position:absolute;
left:0px;
bottom:0px;
background:#000;
color:#fff;
width:100%;
z-index:8;
padding: 5px 10px;
opacity: 0.8;
overflow: hidden;
display: none;
-moz-opacity: 0.8;
filter:alpha(opacity=8);
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box; /* Opera/IE 8+ */
}
.nivo-caption p {
padding:5px;
margin:0;
}
.nivo-caption a {
display:inline !important;
}
.nivo-html-caption {
display:none;
}
/* Direction nav styles (e.g. Next & Prev) */
.nivo-directionNav a {
position:absolute;
top:45%;
z-index:9;
cursor:pointer;
}
.nivo-prevNav {
left:0px;
}
.nivo-nextNav {
right:0px;
}
/* Control nav styles (e.g. 1,2,3...) */
.nivo-controlNav {
position: absolute;
left: 0;
bottom: -41px;
z-index: 10;
width: 100%;
height: 30px;
text-align: center;
padding: 5px 0;
border-top: 1px solid #333;
background: #333;
background: -moz-linear-gradient(top, #565656 0%, #333333 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#565656), color-stop(100%,#333333)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #565656 0%,#333333 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #565656 0%,#333333 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #565656 0%,#333333 100%); /* IE10+ */
background: linear-gradient(to bottom, #565656 0%,#333333 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#565656', endColorstr='#333333',GradientType=0 ); /* IE6-9 */
opacity: 0.5;
-webkit-transition: all 200ms ease-in-out;
-moz-transition: all 200ms ease-in-out;
-o-transition: all 200ms ease-in-out;
transition: all 200ms ease-in-out;
}
.theme-bar .nivo-controlNav {
bottom: 0;
opacity: 1;
}
.nivo-controlNav a {
display:inline-block;
width:22px;
height:22px;
background:url(bullets.png) no-repeat;
text-indent:-9999px;
border:0;
margin: 5px 2px 0 2px;
cursor: pointer;
}
.nivo-controlNav a.active {
background-position:0 -22px;
}
这是另一个 CSS 文件。 bar.css:
.theme-bar.slider-wrapper {
position: relative;
border: 1px solid #333;
overflow: hidden;
}
.theme-bar .nivoSlider {
position:relative;
background:#fafafa url(loading.gif) no-repeat 50% 50%;
}
.theme-bar .nivoSlider img {
position:absolute;
top:0px;
left:0px;
display:none;
}
.theme-bar .nivoSlider a {
border:0;
display:block;
}
.theme-bar .nivo-controlNav {
position: absolute;
left: 0;
bottom: -41px;
z-index: 10;
width: 100%;
height: 30px;
text-align: center;
padding: 5px 0;
border-top: 1px solid #333;
background: #333;
background: -moz-linear-gradient(top, #565656 0%, #333333 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#565656), color-stop(100%,#333333)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #565656 0%,#333333 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #565656 0%,#333333 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #565656 0%,#333333 100%); /* IE10+ */
background: linear-gradient(to bottom, #565656 0%,#333333 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#565656', endColorstr='#333333',GradientType=0 ); /* IE6-9 */
opacity: 0.5;
-webkit-transition: all 200ms ease-in-out;
-moz-transition: all 200ms ease-in-out;
-o-transition: all 200ms ease-in-out;
transition: all 200ms ease-in-out;
}
.theme-bar:hover .nivo-controlNav {
bottom: 0;
opacity: 1;
}
.theme-bar .nivo-controlNav a {
display:inline-block;
width:22px;
height:22px;
background:url(bullets.png) no-repeat;
text-indent:-9999px;
border:0;
margin: 5px 2px 0 2px;
}
.theme-bar .nivo-controlNav a.active {
background-position:0 -22px;
}
.theme-bar .nivo-directionNav a {
display:block;
border:0;
color: #fff;
text-transform: uppercase;
top: auto;
bottom: 10px;
z-index: 11;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 13px;
line-height: 20px;
opacity: 0.5;
-webkit-transition: all 200ms ease-in-out;
-moz-transition: all 200ms ease-in-out;
-o-transition: all 200ms ease-in-out;
transition: all 200ms ease-in-out;
}
.theme-bar a.nivo-nextNav { right: -50px; }
.theme-bar a.nivo-prevNav { left: -50px; }
.theme-bar:hover a.nivo-nextNav {
right: 15px;
opacity: 1;
}
.theme-bar:hover a.nivo-prevNav {
left: 15px;
opacity: 1;
}
.theme-bar .nivo-directionNav a:hover { color: #ddd; }
.theme-bar .nivo-caption {
font-family: Helvetica, Arial, sans-serif;
-webkit-transition: all 200ms ease-in-out;
-moz-transition: all 200ms ease-in-out;
-o-transition: all 200ms ease-in-out;
transition: all 200ms ease-in-out;
}
.theme-bar:hover .nivo-caption {
bottom: 41px;
}
.theme-bar .nivo-caption a {
color:#fff;
border-bottom:1px dotted #fff;
}
.theme-bar .nivo-caption a:hover {
color:#fff;
}
.theme-bar .nivo-controlNav.nivo-thumbs-enabled {
width: 100%;
}
.theme-bar .nivo-controlNav.nivo-thumbs-enabled a {
width: auto;
height: auto;
background: none;
margin-bottom: 5px;
}
.theme-bar .nivo-controlNav.nivo-thumbs-enabled img {
display: block;
width: 120px;
height: auto;
}
这是我使用的脚本。这是 Nivo Slider Jquery 插件附带的默认脚本,只是我对设置进行了一些改动。我只向您展示我编辑的脚本,因为我限制在 30000 个字符以内:
//Default settings
$.fn.nivoSlider.defaults = {
effect: 'fade',
slices: 15,
boxCols: 8,
boxRows: 4,
animSpeed: 550,
pauseTime: 3500,
startSlide: 0,
directionNav: false,
controlNav: true,
controlNavThumbs: false,
pauseOnHover: true,
manualAdvance: false,
prevText: 'Prev',
nextText: 'Next',
randomStart: false,
beforeChange: function(){},
afterChange: function(){},
slideshowEnd: function(){},
lastSlide: function(){},
afterLoad: function(){}
};
$.fn._reverse = [].reverse;
})(jQuery);
同样,问题在于图像看起来被放大了,您无法看到全部。我尝试将 .nivoSlider 类的宽度设置为图像的确切宽度,但它仍然无法正常工作。我在这里先向您的帮助表示感谢! 是的,我确实用这段代码激活了 Jquery:
<script type="text/javascript">
$(window).load(function() {
$('#slider').nivoSlider();
});
</script>
评论: 图像的大小是我想要的。我认为是包裹 slider 的 div 有问题。我只是不明白为什么图像是这样的。通常 Nivo Slider 会自行调整大小以适合图像,但它会调整我的图像大小以适合它。
最佳答案
您应该在将图像显示给用户之前调整图像的大小。如果图像已经在服务器上,您可以使用 mogrify cammond from ImageMagik如果它是 Linux 服务器。
关于jquery - Nivo Slider Jquery 插件 - 图像自动调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12630713/
很好奇,就使用rubyonrails自动化单元测试而言,你们正在做什么?您是否创建了一个脚本来在cron中运行rake作业并将结果邮寄给您?git中的预提交Hook?只是手动调用?我完全理解测试,但想知道在错误发生之前捕获错误的最佳实践是什么。让我们理所当然地认为测试本身是完美无缺的,并且可以正常工作。下一步是什么以确保他们在正确的时间将可能有害的结果传达给您? 最佳答案 不确定您到底想听什么,但是有几个级别的自动代码库控制:在处理某项功能时,您可以使用类似autotest的内容获得关于哪些有效,哪些无效的即时反馈。要确保您的提
我的目标是转换表单输入,例如“100兆字节”或“1GB”,并将其转换为我可以存储在数据库中的文件大小(以千字节为单位)。目前,我有这个:defquota_convert@regex=/([0-9]+)(.*)s/@sizes=%w{kilobytemegabytegigabyte}m=self.quota.match(@regex)if@sizes.include?m[2]eval("self.quota=#{m[1]}.#{m[2]}")endend这有效,但前提是输入是倍数(“gigabytes”,而不是“gigabyte”)并且由于使用了eval看起来疯狂不安全。所以,功能正常,
在选择我想要运行操作的频率时,唯一的选项是“每天”、“每小时”和“每10分钟”。谢谢!我想为我的Rails3.1应用程序运行调度程序。 最佳答案 这不是一个优雅的解决方案,但您可以安排它每天运行,并在实际开始工作之前检查日期是否为当月的第一天。 关于ruby-如何每月在Heroku运行一次Scheduler插件?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/8692687/
我对最新版本的Rails有疑问。我创建了一个新应用程序(railsnewMyProject),但我没有脚本/生成,只有脚本/rails,当我输入ruby./script/railsgeneratepluginmy_plugin"Couldnotfindgeneratorplugin.".你知道如何生成插件模板吗?没有这个命令可以创建插件吗?PS:我正在使用Rails3.2.1和ruby1.8.7[universal-darwin11.0] 最佳答案 随着Rails3.2.0的发布,插件生成器已经被移除。查看变更日志here.现在
我收到这个错误:RuntimeError(自动加载常量Apps时检测到循环依赖当我使用多线程时。下面是我的代码。为什么会这样?我尝试多线程的原因是因为我正在编写一个HTML抓取应用程序。对Nokogiri::HTML(open())的调用是一个同步阻塞调用,需要1秒才能返回,我有100,000多个页面要访问,所以我试图运行多个线程来解决这个问题。有更好的方法吗?classToolsController0)app.website=array.join(',')putsapp.websiteelseapp.website="NONE"endapp.saveapps=Apps.order("
rails中是否有任何规定允许站点的所有AJAXPOST请求在没有authenticity_token的情况下通过?我有一个调用Controller方法的JqueryPOSTajax调用,但我没有在其中放置任何真实性代码,但调用成功。我的ApplicationController确实有'request_forgery_protection'并且我已经改变了config.action_controller.consider_all_requests_local在我的environments/development.rb中为false我还搜索了我的代码以确保我没有重载ajaxSend来发送
我有带有Logo图像的公司模型has_attached_file:logo我用他们的Logo创建了许多公司。现在,我需要添加新样式has_attached_file:logo,:styles=>{:small=>"30x15>",:medium=>"155x85>"}我是否应该重新上传所有旧数据以重新生成新样式?我不这么认为……或者有什么rake任务可以重新生成样式吗? 最佳答案 参见Thumbnail-Generation.如果rake任务不适合你,你应该能够在控制台中使用一个片段来调用重新处理!关于相关公司
我们目前正在为ROR3.2开发自定义cms引擎。在这个过程中,我们希望成为我们的rails应用程序中的一等公民的几个类类型起源,这意味着它们应该驻留在应用程序的app文件夹下,它是插件。目前我们有以下类型:数据源数据类型查看我在app文件夹下创建了多个目录来保存这些:应用/数据源应用/数据类型应用/View更多类型将随之而来,我有点担心应用程序文件夹被这么多目录污染。因此,我想将它们移动到一个子目录/模块中,该子目录/模块包含cms定义的所有类型。所有类都应位于MyCms命名空间内,目录布局应如下所示:应用程序/my_cms/data_source应用程序/my_cms/data_ty
我正在尝试使用Ruby2.0.0和Rails4.0.0提供的API从imgur中提取图像。我已尝试按照Ruby2.0.0文档中列出的各种方式构建http请求,但均无济于事。代码如下:require'net/http'require'net/https'defimgurheaders={"Authorization"=>"Client-ID"+my_client_id}path="/3/gallery/image/#{img_id}.json"uri=URI("https://api.imgur.com"+path)request,data=Net::HTTP::Get.new(path
2022/8/4更新支持加入水印水印必须包含透明图像,并且水印图像大小要等于原图像的大小pythonconvert_image_to_video.py-f30-mwatermark.pngim_dirout.mkv2022/6/21更新让命令行参数更加易用新的命令行使用方法pythonconvert_image_to_video.py-f30im_dirout.mkvFFMPEG命令行转换一组JPG图像到视频时,是将这组图像视为MJPG流。我需要转换一组PNG图像到视频,FFMPEG就不认了。pyav内置了ffmpeg库,不需要系统带有ffmpeg工具因此我使用ffmpeg的python包装p