首页 > 其他分享 >css37 CSS Image Gallery

css37 CSS Image Gallery

时间:2024-06-01 16:22:03浏览次数:17  
标签:Image here gallery width Add CSS div image css37

https://www.w3schools.com/css/css_image_gallery.asp

 

CSS can be used to create an image gallery.

 

Image Gallery

The following image gallery is created with CSS:

<!DOCTYPE html>
<html>
<head>
<style>
div.gallery {
  margin: 5px;
  border: 1px solid #ccc;
  float: left;
  width: 180px;
}

div.gallery:hover {
  border: 1px solid #777;
}

div.gallery img {
  width: 100%;
  height: auto;
}

div.desc {
  padding: 15px;
  text-align: center;
}
</style>
</head>
<body>

<div class="gallery">
  <a target="_blank" href="img_5terre.jpg">
    <img src="img_5terre.jpg" alt="Cinque Terre" width="600" height="400">
  </a>
  <div class="desc">Add a description of the image here</div>
</div>

<div class="gallery">
  <a target="_blank" href="img_forest.jpg">
    <img src="img_forest.jpg" alt="Forest" width="600" height="400">
  </a>
  <div class="desc">Add a description of the image here</div>
</div>

<div class="gallery">
  <a target="_blank" href="img_lights.jpg">
    <img src="img_lights.jpg" alt="Northern Lights" width="600" height="400">
  </a>
  <div class="desc">Add a description of the image here</div>
</div>

<div class="gallery">
  <a target="_blank" href="img_mountains.jpg">
    <img src="img_mountains.jpg" alt="Mountains" width="600" height="400">
  </a>
  <div class="desc">Add a description of the image here</div>
</div>

</body>
</html>

 

More Examples

Responsive Image Gallery

How to use CSS media queries to create a responsive image gallery that will look good on desktops, tablets and smart phones.

<!DOCTYPE html>
<html>
<head>
<style>
div.gallery {
  border: 1px solid #ccc;
}

div.gallery:hover {
  border: 1px solid #777;
}

div.gallery 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>Responsive Image Gallery</h2>

<h4>Resize the browser window to see the effect.</h4>

<div class="responsive">
  <div class="gallery">
    <a target="_blank" href="img_5terre.jpg">
      <img src="img_5terre.jpg" alt="Cinque Terre" width="600" height="400">
    </a>
    <div class="desc">Add a description of the image here</div>
  </div>
</div>


<div class="responsive">
  <div class="gallery">
    <a target="_blank" href="img_forest.jpg">
      <img src="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="gallery">
    <a target="_blank" href="img_lights.jpg">
      <img src="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="gallery">
    <a target="_blank" href="img_mountains.jpg">
      <img src="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;">
  <p>This example use media queries to re-arrange the images on different screen sizes: for screens larger than 700px wide, it will show four images side by side, for screens smaller than 700px, it will show two images side by side. For screens smaller than 500px, the images will stack vertically (100%).</p>
  <p>You will learn more about media queries and responsive web design later in our CSS Tutorial.</p>
</div>

</body>
</html>

 

标签:Image,here,gallery,width,Add,CSS,div,image,css37
From: https://www.cnblogs.com/emanlee/p/18226072

相关文章

  • css35 CSS Navigation Bar
    https://www.w3schools.com/css/css_navbar.aspDemo:NavigationBars NavigationBarsHavingeasy-to-usenavigationisimportantforanywebsite.WithCSSyoucantransformboringHTMLmenusintogood-lookingnavigationbars.NavigationBar=ListofLi......
  • css34 CSS Opacity / Transparency
    https://www.w3schools.com/css/css_image_transparency.asp CSSOpacity/Transparency  Theopacitypropertyspecifiestheopacity/transparencyofanelement.TransparentImageTheopacitypropertycantakeavaluefrom0.0-1.0.Thelowerthevalue,......
  • delphi Image32 之 快速入门
     官方快速入门,加上了一些注解[从WORD粘贴后失去了样式]TImage32类是关键。TImage32 对象包含单个图像,所有图像操作都作用于此对象。usesImg32; //引用单元...img:=TImage32.Create; //创建TImage32对象//执行一些其它操作img.Free; //用完了要释放图像存储......
  • HTML+CSS+JS 熊猫登录表单
    效果演示实现了一个可爱的熊猫登录界面,页面背景使用了渐变色,熊猫的头部和身体使用了圆形和椭圆形的边框,使用了CSS的伪元素和阴影效果来实现熊猫的手和脚。登录框使用了flex布局,包括用户名和密码的输入框和登录按钮,使用了CSS的过渡效果和伪类来实现输入框的动态效果。整个......
  • QImage和QPixmap的区别和使用
    一、基本概念和特点QImage概念:QImage是Qt库中用于处理图像数据的一个类。它提供了直接访问和操作图像像素的接口。特点:可以独立于屏幕分辨率和设备处理图像。支持读取和保存多种图像格式,如PNG、JPEG、BMP等。可以在没有图形界面的情况下使用,例如服务器端图像处理。内部存......
  • css33 CSS Layout - Horizontal & Vertical Align
    https://www.w3schools.com/css/css_align.asp  CenterAlignElementsTohorizontallycenterablockelement(like<div>),usemargin:auto;Settingthewidthoftheelementwillpreventitfromstretchingouttotheedgesofitscontainer.Theele......
  • css32 CSS Layout - display: inline-block
    https://www.w3schools.com/css/css_inline-block.aspThedisplay:inline-blockValueComparedtodisplay:inline,themajordifferenceisthatdisplay:inline-blockallowstosetawidthandheightontheelement.Also,withdisplay:inline-block,thetop......
  • HTML期末学生大作业-基于班级校园我的校园网页设计与实现html+css+javascript
    ......
  • HTML期末作业-基于HTML+CSS+JavaScript制作学生信息管理系统模板
    ......
  • css特殊效果和页面布局
    特殊效果圆角边框:div{border-radius:20px 10px 50px 30px;}四个属性值按顺时针排列,左上的1/4圆半径为20px,右上10,右下50,左下30。div{border-radius:20px;}四角都为20px。div{border-radius:20px10px;}左上和右下20px,右上左下10px。div{border-radius:20px10p......