index.html
2030 ワード
* {
padding: 0;
margin: 0;
}
ul, li {
list-style-type: none;
}
#content {
width: 60%;
height: 60%;
top: 20%;
left: 20%;
overflow: hidden;
position: absolute;
border: 1px solid #ccc;
}
.content-wrap {
position: relative;
}
.content-wrap > li {
width: 100%;
height: 100%;
background: #cae1ff;
color: red;
float: left;
overflow: hidden;
position: relative;
}
li:nth-child(2) {
background: #9bcd9b;
}
li:nth-child(3){
background: yellow;
}
- 1
- 2
- 3
var container = $("#content");
var element = container.find(":first");
var slides = element.find("li");
var width = container.width();
var height = container.height();
element.css({
width : (slides.length * width) + 'px';
height : height + 'px';
});
$.each(slides, function(index) {
var slide = slides.eq(index); // li
slide.css({
width : width + 'px';
height : height + 'px';
});
});