CSS 图片廊

一、示例一

代码:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS教程</title>
<style>
div.img {
margin: 5px;
border: 1px solid #ccc;
float: left;
width: 180px;
} div.img:hover {
border: 1px solid #777;
} div.img img {
width: 100%;
height: auto;
} div.desc {
padding: 15px;
text-align: center;
}
</style>
</head>
<body> <div class="responsive">
<div class="img">
<a target="_blank" href="http://static.runoob.com/images/demo/demo1.jpg">
<img src="http://static.runoob.com/images/demo/demo1.jpg" alt="图片文本描述" width="300" height="200">
</a>
<div class="desc">这里添加图片文本描述</div>
</div>
</div> <div class="responsive">
<div class="img">
<a target="_blank" href="http://static.runoob.com/images/demo/demo2.jpg">
<img src="http://static.runoob.com/images/demo/demo2.jpg" alt="图片文本描述" width="300" height="200">
</a>
<div class="desc">这里添加图片文本描述</div>
</div>
</div> <div class="responsive">
<div class="img">
<a target="_blank" href="http://static.runoob.com/images/demo/demo3.jpg">
<img src="http://static.runoob.com/images/demo/demo3.jpg" alt="图片文本描述" width="300" height="200">
</a>
<div class="desc">这里添加图片文本描述</div>
</div>
</div> <div class="responsive">
<div class="img">
<a target="_blank" href="http://static.runoob.com/images/demo/demo4.jpg">
<img src="http://static.runoob.com/images/demo/demo4.jpg" alt="图片文本描述" width="300" height="200">
</a>
<div class="desc">这里添加图片文本描述</div>
</div>
</div> </body>
</html>

效果:

二、示例二

代码:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS代码</title>
<style>
div.img {
border: 1px solid #ccc;
} div.img:hover {
border: 1px solid #777;
} div.img img {
width: 100%;
height: auto;
} div.desc {
padding: 15px;
text-align: center;
} * {
box-sizing: border-box;
} .responsive {
padding: 0 6px;
float: left;
width: 24.99999%;
} @media only screen and (max-width: 700px){
.responsive {
width: 49.99999%;
margin: 6px 0;
}
} @media only screen and (max-width: 500px){
.responsive {
width: 100%;
}
} .clearfix:after {
content: "";
display: table;
clear: both;
}
</style>
</head>
<body> <h2 style="text-align:center">响应式图片相册</h2> <div class="responsive">
<div class="img">
<a target="_blank" href="img_fjords.jpg">
<img src="http://www.runoob.com/wp-content/uploads/2016/04/img_fjords.jpg" alt="Trolltunga Norway" width="300" height="200">
</a>
<div class="desc">Add a description of the image here</div>
</div>
</div> <div class="responsive">
<div class="img">
<a target="_blank" href="img_forest.jpg">
<img src="http://www.runoob.com/wp-content/uploads/2016/04/img_forest.jpg" alt="Forest" width="600" height="400">
</a>
<div class="desc">Add a description of the image here</div>
</div>
</div> <div class="responsive">
<div class="img">
<a target="_blank" href="img_lights.jpg">
<img src="http://www.runoob.com/wp-content/uploads/2016/04/img_lights.jpg" alt="Northern Lights" width="600" height="400">
</a>
<div class="desc">Add a description of the image here</div>
</div>
</div> <div class="responsive">
<div class="img">
<a target="_blank" href="img_mountains.jpg">
<img src="http://www.runoob.com/wp-content/uploads/2016/04/img_mountains.jpg" alt="Mountains" width="600" height="400">
</a>
<div class="desc">Add a description of the image here</div>
</div>
</div> <div class="clearfix"></div> <div style="padding:6px;"> <h4>重置浏览器大小查看效果</h4>
</div> </body>
</html>

效果:

CSS 图片廊的更多相关文章

  1. CSS:CSS 图片廊

    ylbtech-CSS:CSS 图片廊 1.返回顶部 1. CSS 图片廊 以下是使用CSS创建图片廊: 图片廊 以下是使用 CSS 创建图片廊: 实例 <div class="res ...

  2. 几种垂直居中的方式及CSS图片替换技术

    由于块级元素的高度是可以设置的,所以对于块级元素的垂直居中比较简单. 方法一: 在不定高的情况下,把元素的上下内边距设为同一个值即可实现,即padding :10px   0; 以上方法针对块级元素和 ...

  3. css图片叠加和底部定位

    css图片叠加和底部定位 css图片叠加 两张图片需要叠在一起显示,如何定位 容器先对定位 第一张图片正常摆放 第二张图片绝对定位,top:0px 这样便实现了两张图片叠加在一起了,设置z-index ...

  4. 转:利用node压缩、合并js,css,图片

    1.安装nodejs http://nodejs.org/ 2.安装各自的node package js我用的是UglifyJS github地址:https://github.com/mishoo/ ...

  5. CSS图片列表

    1.效果图: 2.Example Source Code <h3><a href="http://www.52css.com/">我爱CSS画廊</a ...

  6. 漂亮的自适应宽度的多色彩CSS图片按钮

    一.素材               二.效果 三.CSS *{padding:0;margin:0} /*----------------------------------- 自适应宽度图片按钮 ...

  7. css图片垂直居中

    css图片垂直居中一.style代码 .case-pic{ height: 125px; position: relative; text-align: center } .case-pic span ...

  8. css 图片 圆形显示区域

    css 图片 圆形显示区域 css 和 div 实现 方形图片 圆形显示 点击下载

  9. CSS图片翻转动画技术详解

    因为不断有人问我,现在我补充一下:IE是支持这种技术的!尽管会很麻烦.需要做的是旋转front和back元素,而不是旋转整个容器元素.如果你使用的是最新版的IE,可以忽略这一节.IE10+是支持的,I ...

随机推荐

  1. JZOJ.5288【NOIP2017模拟8.17】球场大佬

    Description       每天下午,古猴都会去打羽毛球.但是古猴实在是太强了,他必须要到一些比较强的场去打.但是每个羽毛球场都有许多的人排着队,每次都只能上四个人,每个人都有自己的能力值,然 ...

  2. ios 如何对UITableView中的内容进行排序

    - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSI ...

  3. spring boot 加载jsp

    1.spring boot启动类继承SpringBootServletInitializer ,并且重写configure方法 package com.springapp.mvc;import jav ...

  4. 报错分析---->jsp自定义标签:Unable to load tag handler class

    Unable to load tag handler class 无法加载标签处理程序类 处理自定义标签的类中如下: 调用自定义标签的jsp中如下:

  5. Clairewd’s message--hdu4300(Next数组的运用)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4300 题意就是给你26的字母的加密方式,然后又给了一个串s1是包含加密后的和没有加密的但是没有加密的可 ...

  6. 浅谈virtualenv(虚拟环境)

    简介 virtualenv为应用提供了隔离的Python运行环境,解决了不同应用间多版本的冲突问题. 例如: 如果我们要同时开发多个应用程序,那这些应用程序都会共用一个Python,就是安装在系统的P ...

  7. servlet实现多文件打包下载

    当用户一次下载多个文件时.普通情况是,每下载一个文件,均要弹出一个下载的对话框.这给用户造成了非常大不便. 比較理想的情况是,用户选择多个文件后.server后端直接将多个文件打包为zip.以下贴出实 ...

  8. webpack打包页面空白的解决方法

  9. (2.5)Mysql之SQL基础——数据类型

    (2.5)Mysql之SQL基础——数据类型 关键词:mysql数据类型 目录: 一.整数型 二.小数型(以下均不能使用无符号) 三.日期时间型 四.字符串型 一.整数型 额外参数示例: int [( ...

  10. sql server中使用xp_cmdshell

    关键词:sql server开启高级配置,使用Bat,cmdshell 1.sql server中使用xp_cmdshell --允许配置高级选项 GO RECONFIGURE GO . --开启xp ...