- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以我在我的 php 代码中填充了三个 javascript 数组,以保存照片的尺寸及其来源。然后,假设尺寸不等于使用 php 的 325x300,我只会在我的页面上显示图像的 325x300 缩略图。
当用户单击其中一个缩略图时,我希望它在 #largeImage div 中打开全尺寸图像,然后取消隐藏它。到目前为止,这是可行的。
但是,我在让潜水调整图像尺寸时遇到了麻烦。我正在使用 php 来获取尺寸(除非在 jQuery 中有更好的方法)。此时 div 没有调整大小,我不确定从这里去哪里。我已经包含了 jquery 和来自 php 代码的输出 html。
<html>
<head>
<style>
@import "album_style.css";
</style>
<script type="text/javascript" src="jquery-1.10.2.min.js"></script>
<script>
$(document).ready(function() {
var active_index;
var source_image;
var index;
var style;
$('#largeImage').hide();
$('#imageBackground').hide();
$('#gallery img').click(function() {
index = parseInt( $(this).attr('value'));
$('#largImage').height(parseInt(picture_y[index]) + 20);
$('#largImage').width(parseInt(picture_x[index]) + 50);
$('#largeImage img').attr('src', picture_list[index]);
$('#largeImage').show() ;
$('#imageBackground').show() ;
active_index = index ;
});
$('.next').click(function( event ){
active_index = active_index + 1;
max_index = array_size - 1;
if(active_index == array_size)
{
active_index = 0 ;
}
source_image = $('#largeImage img').attr('src');
var newSrc = $('#largeImage img').attr('src')
.replace(source_image, picture_list[ active_index]);
$('#largeImage img').attr('src', newSrc);
});
$('.back').click(function(event) {
active_index = active_index - 1;
if( active_index < 0 )
{
active_index = array_size - 1;
}
source_image = $('#largeImage img').attr('src') ;
var newSrc = $('#largeImage img').attr('src')
.replace(source_image, picture_list[active_index]);
$('#largeImage img').attr('src', newSrc);
}) ;
$('.close').click(function() {
$('#largeImage').hide();
$('#imageBackground').hide();
});
});
</script>
</head>
<body>
<div id="container">
<img src="websitebanner.jpg">
</div>
<div id="nav">
<ul>
<li>
<a href="index.php">Home</a>
</li>
<li>
<a href="news.php">News</a>
</li>
<li>
<a href="events.php">Events</a>
</li>
<li>
<a href="#">The Team</a>
<ul>
<li><a href="roster.php">Roster</a></li>
<li><a href="albums.php">Albums</a></li>
</ul>
</li>
<li>
<a href="sponsors.php">Sponsors</a>
</li>
<li>
<a href="social.php">Contact Us</a>
</li>
</ul>
</div>
<div class='pageHeader'>Test1</div>
<script type='text/javascript'>
var array_size = 3;
</script>
<script type='text/javascript'>
var picture_list = new Array(array_size);
var picture_x = new Array(array_size);
var picture_y = new Array(array_size);
</script>
<div id='imageBackground'></div>
<div id='largeImage'>
<input type='button' class='close' value='X'>
<input type='button' class='back' value='<<'>
<img src='Test1/Image3.jpg'>
<input type='button' class='next' value='>>'>
</div>
<div id='gallery'>
<div id='thumbpanel'>
<img value='0' src='Thumbnails/Thumb_Image6.jpg'>
<script type='text/javascript'>
picture_list[0] = 'Albums/Test1/Image6.jpg';
picture_x[0] = 386;
picture_y[0] = 233;
</script>
<img value='1' src='Thumbnails/Thumb_Ellie 012.jpg'>
<script type='text/javascript'>
picture_list[1] = 'Albums/Test1/Ellie 012.jpg';
picture_x[1] = 3264;
picture_y[1] = 2448;
</script>
<img value='2' src='Albums/Test1/concealedjesspermit.jpg'>
<script type='text/javascript'>
picture_list[2] = 'Albums/Test1/concealedjesspermit.jpg';
picture_x[2] = 325;
picture_y[2] = 300;
</script>
Page 1
</div>
</div>
</body>
</html>
这是我目前正在使用的 CSS。如果我删除 jQuery block 中的大小限制,div 不会调整大小。
{margin: 0; padding: 0;}
@import url(http://fonts.googleapis.com/css?family=Finger+Paint);
@import url(http://fonts.googleapis.com/css?family=Russo+One);
@font-face
{
font-family: "DayPosterBlack";
src: url('dayposterblack.tff');
}
body{
background-color: #303030;
background:#222 url(dark_wall.png);
}
#container {
width: 1000px;
height: 425px;
overflow: hidden;
margin: 25px auto;
background:#303030;
}
.photobanner {
height: 233px;
width: 3550px;
margin-bottom: 80px;
}
.first {
-webkit-animation: bannermove 30s linear infinite;
-moz-animation: bannermove 30s linear infinite;
-o-animation: bannermove 30s liner infinite;
animation: bannermove 30s linear infinite;
}
.photobanner img{
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-ms-transition: all 0.5s ease;
-o-transition: all 0.5s ease ;
transition: all 0.5s ease;
}
.photobanner img:hover {
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
-o-transform: scale(1.1);
-ms-transform: scale(1.1);
transform: scale(1.1);
cursor: pointer;
-webkit-box-shadow: 0px 3px 5px rgba(0,0,0,0.2);
-moz-box-shadow: 0px 3px 5px rgba(0,0,0,0.2);
box-shadow: 0px 3px 5px rgba(0,0,0,0.2);
}
@keyframes "bannermove" {
0%{
margin-left: 0px;
}
100%{
margin-left: -2125px;
}
}
@-moz-keyframes "bannermove" {
0%{
margin-left: 0px;
}
100%{
margin-left: -2125px;
}
}
@-webkit-keyframes "bannermove" {
0%{
margin-left: 0px;
}
100%{
margin-left: -2125px;
}
}
@-ms-keyframes "bannermove" {
0%{
margin-left: 0px;
}
100%{
margin-left: -2125px;
}
}
@-o-keyframes "bannermove" {
0%{
margin-left: 0px;
}
100%{
margin-left: -2125px;
}
}
#nav {
font-family: 'DayPosterBlack', normal;
position: relative;
background-color: black ;
width: 1000px;
height:25px;
font-size:12px;
color:#ffff33;
margin: 0px auto;
z-index: 10;
}
#nav ul {
list-style-type: none;
padding:0px;
}
#nav ul li {
float: left;
position: relative;
}
#nav ul li a {
text-align: center;
padding:55px;
padding-top: 5px;
padding-bottom: 5px;
display:block;
text-decoration:none;
color:#ffff33;
}
#nav ul li ul {
display: none
}
#nav ul li:hover ul {
display: block;
position: absolute;
}
#nav ul li:hover ul li a {
display:block;
background:#000000;
color:#ffff33;
width: 75px;
text-align: center;
border-bottom: 1px solid #f2f2f2;
border-right: none;
}
#nav ul li:hover ul li a:hover {
background:#303030;
color:#fff;
border-bottom: 1px solid #ffff33
}
#controlpanel {
font-family: 'russo one', normal;
position: relative;
background: url('carbon_black.jpg');
width: 1000px;
height:25px;
font-size:12px;
color:#ffff33;
margin: 0px auto;
z-index: 0;
}
#controlpanel ul {
list-style-type: none;
padding:0px;
}
#controlpanel ul li {
float: left;
position: relative;
}
#controlpanel ul li a {
text-align: center;
padding:25px;
padding-top: 5px;
padding-bottom: 5px;
display:block;
text-decoration:none;
color:#ffff33;
}
#controlpanel ul li ul {
display: none
}
#controlpanel ul li:hover ul {
display: block;
position: absolute;
}
#controlpanel ul li:hover ul li a {
display:block;
background:#000000;
color:#ffff33;
width: 75px;
text-align: center;
border-bottom: 1px solid #f2f2f2;
border-right: none;
}
#controlpanel ul li:hover ul li a:hover {
background:#303030;
color:#fff;
border-bottom: 1px solid #ffff33
}
.album_container{
margin: 0px auto;
position: relative;
width: 1000px;
}
.album_box{
position: relative;
margin: 0px auto;
float: left;
text-align: center;
color: #ffff33;
width:325px;
height: 300px;
padding-right: 8px;
padding-bottom: 20px;
}
.album_box a{
font-family: 'russo one', sans serif ;
color: #ffff33;
text-align: center;
text-decoration: none ;
}
.album_box img{
position: relative;
margin: 0px;
display: block;
}
.album_box p{
font-family: 'russo one', sans serif;
color: #ffff33;
text-align: center;
position: absolute;
text-decoration: none;
margin: 0px;
z-index: 200px;
display: block;
background-color: #101010;
top: 280px;
}
.spacer {
position: relative;
width: 12px;
}
#gallery{
margin: 10px auto;
width: 1000px;
}
#thumpanel{
float: left;
width: 1000px;
border: 3px outset #101010;
background: url('dark_wall copydarker.png');
}
#thumbpanel img{
position: relative;
float: left;
padding: 4px;
}
#imageBackground{
position: fixed;
background: #303030;
opacity: 0.6 ;
width: 1500px;
height: 2000px;
top: 50%;
left: 50%;
margin: auto;
z-index: 20 ;
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate( -50%, -50%);
transform: translate( -50%, -50%);
}
#largeImage{
position: fixed;
background: #202020 ;
top: 50%;
left: 50%;
margin: auto;
z-index: 25 ;
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate( -50%, -50%);
transform: translate( -50%, -50%);
}
#largeImage img{
position: absolute;
top: 0 ;
left: 0;
right: 0;
bottom: 0;
margin: auto ;
}
.return{
position: relative;
margin: 10px auto;
}
.back{
float: left;
position: relative;
margin-top: 240px;
margin-left: 20px;
background: #101010;
text-align: center;
color: #ffff33;
border: 2px outset #000000;
text-decoration: none;
width: 35px;
height: 35px;
vertical-align: middle;
}
.next{
float: right;
position: relative;
margin-top: 240px;
margin-right: -15px;
background: #101010;
text-align: center;
color: #ffff33;
border: 2px outset #000000;
text-decoration: none;
width: 35px;
height: 35px;
vertical-align: middle;
}
.close{
float: right;
position: relative;
margin-top: 0px;
margin-right: 0px;
background: #101010 ;
text-align: center;
color: #ffff33;
border: 2px outset #000000;
text-decoration: none;
width: 35px;
height: 35px;
}
#largeImage input [type='button']:hover{
background: #303030 ;
}
.data_container{
position: relative;
width: 1000px;
height: 1000px;
margin: 20px auto;
}
.data_entry{
position: relative ;
width: 1000px;
margin: 5px auto ;
}
.data_entry table{
margin: 0px auto;
font-size: 16px;
color: #ffff33 ;
}
.data_entry form{
background: url('dark_wall copydarker.png') ;
border: 3px outset #000000;
margin: 0px auto;
font-size: 16px;
color: #ffff33 ;
}
.success{
position: relative;
width: 1000px;
background: #ffff33 ;
margin: 5px auto ;
font-size: 20px;
}
.error{
position: relative;
width: 1000px;
background: #ff0000;
margin: 5px auto;
font-size: 20px;
}
.button{
margin: 5px auto ;
width: 180px;
display: block;
background: #101010;
text-align: center;
color: #ffff33;
border: 2px outset #000000;
text-decoration: none;
vertical-align: middle;
}
.button a:hover{
background: #303030 ;
}
.bottom_button{
position: relative;
bottom: 0 ;
margin: 5px auto ;
width: 180px;
display: block;
background: #101010;
text-align: center;
color: #ffff33;
border: 2px outset #000000;
text-decoration: none;
vertical-align: middle;
float: bottom ;
}
.bottom_button a:hover{
background: #303030 ;
}
.confirm{
margin: 5px auto ;
width: 180px;
display: block;
background: #101010;
text-align: center;
color: #ffff33;
border: 2px outset #000000;
text-decoration: none;
vertical-align: middle;
}
.confirm a:hover{
background: #303030;
}
.uploaded_photos{
position: relative;
width: 1000px;
height: 500px;
margin: 0px auto ;
background: url('dark_wall copydarker.png') ;
color: #ffff33 ;
text-align: center;
border: 2px outset #000000;
}
.uploaded_photos img{
width: 40% ;
height: 40%;
float: left;
margin: 10px;
}
.pageHeader{
text-align: center ;
color: #ffff33 ;
font-size: 22px;
font-weight: bold ;
background-color: #000000;
font-family: 'russo one', sans serif;
width: 1000px;
height: 25px;
position: relative;
margin: 5px auto;
}
最佳答案
删除行:
$('#largImage').height(parseInt(picture_y[index]) + 20);
$('#largImage').width(parseInt(picture_x[index]) + 50);
并让#largeImage 自动调整大小以适合图像。您可以使用 CSS(最大宽度、最大高度)控制 #largeImage 的最大尺寸。
关于javascript - 根据图片大小设置div高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28518216/
我想使用 Angular.js 转换从服务器获取的图像数据(用于 ionic 框架),我使用了这段代码: $http.post(link, { token: token,
我正在为我的应用制作一个登陆页面。如果它们在 iOS 设备上,我希望它只显示“App Store”图标,但在 Android 上隐藏它。如果它们在 Android 设备上,则只有“Play Store
如何在同一页面上多次显示同一张图片? function xdf(){ for (i=0;ihello world'); } } 此代码显示“hello world”10 次。我想要同样的东西,
您好,我有一个 1px 的 png 文件,我试图将其设置为两个水平相邻的 div 的背景图像。html 和 css 如下:- hi hello css是这样的 div { width: 50%
我的 PHP 项目安装了 Prestashop 1.4.9.0。当我添加一个新产品时,我上传了一个PNG格式的图片,但是当它在客户端显示时,图片是JPG格式的。 如何保留图片扩展名? 最佳答案 在后台
我用 http://www.regexper.com查看一个象形表示正则表达式很多。我想要一种理想的方法: 向站点发送正则表达式 打开显示该表达式的站点 例如,让我们使用正则表达式:"\\s*foo[
我不知道为什么在 MAC OS X (Mail 6.2) 的邮件客户端中图像显示如下: 和其他邮件客户端,如 gmail、outlook 或 private,图像是正确的,看起来像这样: PHP邮件程
我正在使用此处找到的示例。 Mozilla developers 我对这个例子很感兴趣。 function upload(postUrl, fieldName, filePath) { var f
我不知道为什么在 MAC OS X (Mail 6.2) 的邮件客户端中图像显示如下: 和其他邮件客户端,如 gmail、outlook 或 private,图像是正确的,看起来像这样: PHP邮件程
我的问题是如何根据用户在javafx中选择的复选框和/或单选按钮生成带有汽车图片设置的按钮? 我正在用汽车图片模拟汽车经销商网站。用户应该能够通过单击复选框和/或单选按钮选择来过滤显示的图片。 我首先
我正在开发Java客户端,它应该支持多种语言。为了翻译文本,我使用 Java ResourceBoundle,它工作正常。 现在问题出在图像上。客户端应加载大约 50 张图像,这些图像是棋盘游戏的特定
我对 jQuery 还很陌生,但我正在寻找一个简单的脚本,通过淡入和淡出的方式在标题中循环 3 或 4 个背景图像。它们是透明的 png,因此我尝试过的许多 slider 都不起作用。 有什么想法吗?
我有一个 HTML 文档,其中包含本地文件的图像,例如: ios - 物理主体大于它分配给的纹理(图片)
我的 Sprite “physicsBody ”属性之一出现问题。 我已经放置了physicsBody节点“barn ”,直接位于 non-physicsBody 之上节点“mound”没有任何问题。
我想剪切图片的特定部分并用它来将剪切的图像与存储在 HDD 中的另一个图像进行比较。问题是我不知道如何获取源图像的特定部分。我知道要裁剪的图像的位置 (X,Y)。 最佳答案 这将加载原始版本并创建
如何使用裁剪实用程序在 javascript 中实现图像 uploader 。你如何通过 AJAX 提交图像文件?解决方案是否跨域兼容? 最佳答案 要实现具有裁剪功能的图片上传小部件,您必须: 将图像
public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityRes
我想在我的 android 应用程序中显示一个国家的图片。国家必须按地区划分。因此,当用户单击特定区域时,应打开特定屏幕。区域也应该用线分隔,以便用户可以看到区域的开始/结束位置。 这是一个国家的例子
首先我想对这个问题表示歉意,因为我知道已经有很多人问过这个问题了。但我搜索的所有答案都没有解决我的问题。所以希望您考虑这个问题并帮助我解决这个问题。 所以基本上我正在尝试上传图像文件,当我提交它时,会
我几乎有了想要的数据...但需要帮助过滤它。 (图在底部) 下面的查询返回状态为 Member-id5 的所有记录,但我需要对其进行过滤。例如:如果我对等做了一个简单的查询。 (exp_channel
我是一名优秀的程序员,十分优秀!