php图片横排,css div 实现图片从左向右自动横向排列

我们先来看看效果图片再一步步分析实例代码了。

a_33597

首先我们来看这一块代码。

     image

公共相册 

就这代码下面我们来看看css写法。

.gallery {

list-style: none;

margin: 0 0 0 10px;

padding: 0;

}

.gallery dl {

float:left;

overflow: hidden;

height: 180px;

margin-top: 20px;

margin-right: 0;

margin-bottom: 0;

margin-left: 0px;

display: block;

width: 230px;

padding: 10px;

}

.gallery dt {

padding: 0;

position: relative;

height: 130px;

text-align: center;

margin-bottom: 8px;

}

.activityphotoinfo {

background:url(images/albumnameback.png) no-repeat top left;

text-align:center;

height:42px;

width:185px;

margin-top: 0;

margin-right: auto;

margin-bottom: 0;

margin-left: auto;

padding-top: 2px;

padding-right: 0;

padding-bottom: 0;

padding-left: 0;

}

.activityphotoinfo div{

position:relative;

}

.activityphotoinfo .text {

width: 100px;

float: left;

padding-left: 40px;

}

.activityphotoinfo   .text  p {

display: block;

line-height: 16px;

}

div.poll {

display: block;

height: 35px;

width: 40px;

top: 0px;

right: 0px;

cursor:pointer;

}

div.poll a {

display: block;

height: 35px;

width: 40px;

cursor:pointer;

left: 0px;

top: 0px;

right: 0px;

bottom: 0px;

}

.vote{

position:relative;

top:-20px;

left:60px;

display:block;

cursor:pointer;

height:38px;

width:42px;

margin:0 0 0 5px;

border:none;

background:none;

}

.gallery img {

background: #fff;

border: solid 1px #ccc;

padding: 4px;

}

.gallery span {

width: 77px;

height: 27px;

display: block;

position: absolute;

top: -12px;

left: 50px;

background: url(images/tape.png) no-repeat;

}

.gallery a {

text-decoration: none;

}

哈哈我们的css div 实例图片从左向右自动横向排列效果就出来了。原创转载注明www.111cn.net/cssdiv/css.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
你可以使用CSS属性 `overflow-x: scroll;` 和 `white-space: nowrap;` 来实现横向滚动,然后使用JavaScript来控制滚动。 HTML结构: ```html <div class="scroll-container"> <div class="scroll-content"> <div class="scroll-item">1</div> <div class="scroll-item">2</div> <div class="scroll-item">3</div> <div class="scroll-item">4</div> <div class="scroll-item">5</div> <div class="scroll-item">6</div> <div class="scroll-item">7</div> <div class="scroll-item">8</div> <div class="scroll-item">9</div> <div class="scroll-item">10</div> </div> </div> ``` CSS样式: ```css .scroll-container { overflow-x: auto; } .scroll-content { white-space: nowrap; } .scroll-item { display: inline-block; width: 100px; height: 100px; background-color: #ccc; margin-right: 10px; } ``` JavaScript代码: ```javascript const scrollContainer = document.querySelector('.scroll-container'); const scrollContent = document.querySelector('.scroll-content'); scrollContainer.addEventListener('scroll', () => { // 获取滚动距离 const scrollLeft = scrollContainer.scrollLeft; // 获取滚动容器宽度 const containerWidth = scrollContainer.clientWidth; // 获取滚动内容宽度 const contentWidth = scrollContent.offsetWidth; // 判断是否到达右边界 if (scrollLeft + containerWidth >= contentWidth) { console.log('到达右边界'); } // 判断是否到达边界 if (scrollLeft === 0) { console.log('到达边界'); } }); ``` 这样就可以实现横向滚动,并且可以通过监听滚动事件来手动控制。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值