首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >如何在HTML中将4个图像对齐为2*2?

如何在HTML中将4个图像对齐为2*2?
EN

Stack Overflow用户
提问于 2016-09-15 09:48:46
回答 3查看 423关注 0票数 0

我一直在尝试对齐四个图像,这些图像将显示为下面的图片。但是我在每一行后面都有空格。如何删除它们?

另外,有没有一种方法可以让我在所有四个图像相交的中间添加一个示例图像的小缩略图?

此外,我还试图在图片上添加说明文字。目前,它们显示在图像下方。如何将它们添加到图像上?

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
<!DOCTYPE html>
<html>
<body alink="ff0000" bgcolor="ffffff" link="0000ff" text="000000" vlink="800080">

<div>
<div class="transbox" style="width: 50%; height=50%; float: left;">
<img  src="https://s22.postimg.org/61txkvgch/Venture_Capital.jpg" width="100%" />
<div style="position: relative; top:50%; left:45%; width:200px; height:25px">
  <center>
     <font color="Black" size="+2">Looking Into The Future</font>
  </center>
</div> 

<img  src="https://s11.postimg.org/zf842w1mb/Real_Estate.jpg" width="100%" />
<div style="    text-align: center; vertical-align: middle;">
  <center>
     <font color="Black" size="+2">correct one</font>
  </center>
 </div> 
 </div>
 </div>

<div>
<div class="transbox" style="width: 50%; height=50%; float: right;">
<img  src="https://s18.postimg.org/acomst9gp/image.jpg" width="100%" />
<div style="position: relative; top:50%; left:45%; width:200px; height:25px">
  <center>
     <font color="Black" size="+2">Looking Into The Future</font>
  </center>
 </div> 

 <img  src="https://s13.postimg.org/8yima8xvb/Construction.jpg" width="100%" />
 <div style="position: relative; top:50%; left:45%; width:200px; height:25px">
  <center>
     <font color="Black" size="+2">Looking Into The Future</font>
  </center>
 </div> 
</div>
</div>




</div></body>
</html>

JSFiddle链接:

https://jsfiddle.net/8bL4qqr8/

EN

回答 3

Stack Overflow用户

发布于 2016-09-15 10:12:14

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
body{
   background-color:"ffffff";
}

.img-grid{
  width: 50%;
  float:left;
  height:400px;
}

.img-grid img{
  width :100%;
  height:400px;
}
.caption{
  display :none;
}

.img-grid:hover .caption{
  text-align: center;
  display:block;
  background: #000;
  color: #fff;
  font-size:16px;
  font-weight: bold;
  margin-top: -100px;
  padding: 10px;
}
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
<div class="transbox img-grid">
    <img src="https://s22.postimg.org/61txkvgch/Venture_Capital.jpg" />
    <div  class="caption">
            <p>Looking Into The Future</p>
    </div>
</div>
<div class="transbox img-grid">
    <img src="https://s11.postimg.org/zf842w1mb/Real_Estate.jpg" />
    <div class="caption">
            <p>Looking into the future</p>
    </div>
</div>
<div class="transbox img-grid">
    <img src="https://s18.postimg.org/acomst9gp/image.jpg" />
    <div  class="caption">
            <p>Looking Into The Future</p>
    </div>
</div>
<div class="transbox img-grid">
    <img src="https://s13.postimg.org/8yima8xvb/Construction.jpg" />
    <div  class="caption">
            <p>Looking Into The Future</p>
    </div>
</div>

票数 1
EN

Stack Overflow用户

发布于 2016-09-15 10:25:45

您的HTML中有很多不推荐使用的内容。不要在你的身体里使用所有这些链接和文本内容。而不是<center><font>。我用flexbox做了一个你想要的东西的简单片段。我稍微修改了一下你的代码。你可以在这里找到对flexbox的浏览器支持:http://caniuse.com/#search=flexbox

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
body {
  margin: 0;
  padding: 0;
  background-color: #FFFFFF;
}
* {
  box-sizing: border-box;
}
.wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  flex-wrap: wrap;
  flex-direction: row;
}
.transbox {
  position: relative;
  flex: 1 0 50%;
  width: 50%;
  margin: 0;
  padding: 0;
}
.transbox .thumbnail {
  display: block;
  position: absolute;
  width: 100px;
  height: 75px;
}
.transbox:nth-of-type(1) .thumbnail {
  bottom: 0;
  right: 0;
}
.transbox:nth-of-type(2) .thumbnail {
  bottom: 0;
  left: 0;
}
.transbox:nth-of-type(3) .thumbnail {
  top: 0;
  right: 0;
}
.transbox:nth-of-type(4) .thumbnail {
  top: 0;
  left: 0;
}
.transbox img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  float: left;
  margin: 0;
  padding: 0;
  border: 0;
}
.transbox .text {
  position: absolute;
  width: 100%;
  text-align: center;
  color: #FFFFFF;
}
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
<div class="wrapper">
  <div class="transbox">
    <img src="https://s22.postimg.org/61txkvgch/Venture_Capital.jpg" />
    <div class="thumbnail">
      <img src="https://s22.postimg.org/61txkvgch/Venture_Capital.jpg" />
    </div>
    <div class="text">
      <p>Looking Into The Future</p>
    </div>
  </div>
  <div class="transbox">
    <img src="https://s11.postimg.org/zf842w1mb/Real_Estate.jpg" />
    <div class="thumbnail">
      <img src="https://s11.postimg.org/zf842w1mb/Real_Estate.jpg" />
    </div>
    <div class="text">
      <p>Looking into the future</p>
    </div>
  </div>
  <div class="transbox">
    <img src="https://s18.postimg.org/acomst9gp/image.jpg" />
    <div class="thumbnail">
      <img src="https://s18.postimg.org/acomst9gp/image.jpg" />
    </div>
    <div class="text">
      <p>Looking Into The Future</p>
    </div>
  </div>
  <div class="transbox">
    <img src="https://s13.postimg.org/8yima8xvb/Construction.jpg" />
    <div class="thumbnail">
      <img src="https://s13.postimg.org/8yima8xvb/Construction.jpg" />
    </div>
    <div class="text">
      <p>Looking Into The Future</p>
    </div>
  </div>
</div>

票数 1
EN

Stack Overflow用户

发布于 2016-09-15 19:16:57

希望这就是你要找的

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
<!DOCTYPE html>
<html >
<head>
<style type="text/css">
* {
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.item {
  position: relative;
  float: left;
  border: 1px solid #333;

  overflow: hidden;
  width: 50%;
  height: 50%
}
.item img {
  max-width: 100%;

  -moz-transition: all 0.3s;
  -webkit-transition: all 0.3s;
  transition: all 0.3s;
}
.item:hover img {
  -moz-transform: scale(1.1);
  -webkit-transform: scale(1.1);
  transform: scale(1.1);
}
h1 {
  color: white;
  margin: 0;
  padding: 20px;
}
html, body { height: 100%; padding: 0; margin: 0; }
</style>
</head>
<body>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<div class="grow" style="    width: 40%;    position: fixed;    top: 50%;    left: 50%;    margin-top: -100px;    margin-left: -10%;">
<div>
<img class=" align:center"; src="https://s14.postimg.org/6ufixiest/Logo.jpg" width="100%" />
</div>
</div>

<div class="item">
  <img src="http://vindhyaassociates.com/wp-content/uploads/2016/09/IT-1.jpg" alt="pepsi">

  <div class="item-overlay top"></div>
</div>
<div class="item">
  <img src="http://vindhyaassociates.com/wp-content/uploads/2016/09/RealEstate1.jpg" alt="pepsi"  >

  <div class="item-overlay top"></div>
</div>
<div class="item">
  <img src="http://vindhyaassociates.com/wp-content/uploads/2016/09/VentureCapital-1.jpg" alt="pepsi"  >

  <div class="item-overlay top"></div>
</div>
<div class="item">
  <img src="http://vindhyaassociates.com/wp-content/uploads/2016/09/Construction-1.jpg" alt="pepsi"  >

  <div class="item-overlay top"></div>
</div>

<div style="    width: 20%;    position: fixed;    top: 25%;    left: 25%;    margin-top: -100px;    margin-left: -10%;">
<div>
<h1 id="text">
    Construction/Interior Design - Build to Live
  </h1>
</div>
</div>

<div style="    width: 20%;    position: fixed;    top: 25%;    left: 75%;    margin-top: -100px;    margin-left: -10%;">
<div>
<h1 id="text">
    Real Estate - Buy and Sell Potential Properties
  </h1>
</div>
</div>

<div style="    width: 20%;    position: fixed;    top: 75%;    left: 25%;    margin-top: -100px;    margin-left: -10%;">
<div>
<h1 id="text">
     Information Technology - Handling Potential IT Projects
  </h1>
</div>
</div>

<div style="    width: 20%;    position: fixed;    top: 75%;    left: 75%;    margin-top: -100px;    margin-left: -10%;">
<div>
<h1 id="text">
    Venture Capital - Finance for High Growth Potential
  </h1>
</div>
</div>

<div class="grow" style="    width: 20%;    position: fixed;    top: 50%;    left: 50%;    margin-top: -100px;    margin-left: -10%;">
<div>
<img class=" align:center"; src="https://s14.postimg.org/6ufixiest/Logo.jpg" width="100%" />
</div>
</div>
 </body>
</html>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39507999

复制
相关文章
如何将多个 kubeconfig 文件合并为一个?
项目通常有多个 k8s 集群环境,dev、testing、staging、prod,kubetcl 在多个环境中切换,操作集群 Pod 等资源对象,前提条件是将这三个环境的配置信息都写到本地机的 $HOME/.kube/config 文件中。
我的小碗汤
2023/03/19
2.4K0
如何将多个 kubeconfig 文件合并为一个?
python根据已有文件名的文件复制文件到新文件夹中
最近需要对一些图片进行整理,需要从一堆图片中将已经存在在文件中的图片移动到另外一个新的文件夹中,所以就特意就写了一个小玩意方便使用.下面是代码实现:
小海怪的互联网
2019/10/14
3.8K0
Java 将两个Map对象合并为一个Map对象
实现方式是通过 putAll() 方法将多个 map 对象中的数据放到另外一个全新的 map 对象中,代码如下所示,展示了两个 map 对象的合并,如果是多个 map 合并也是用这种方式。
程序员十三
2018/12/28
4.6K0
java将字符串存入GridF并通过id或文件名查询
import static org.bson.codecs.configuration.CodecRegistries.fromProviders; import static org.bson.codecs.configuration.CodecRegistries.fromRegistries; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; i
HUC思梦
2020/09/03
8650
python两个列表合并为字典,一个作为
两个列表合并为一个字典函数list_dic(list1,list2)可以直接复制拿走
py3study
2020/01/17
2.4K0
Java中如何把两个数组合并为一个
http://freewind.me/blog/20110922/350.html
全栈程序员站长
2022/09/07
1.3K0
pycharm创建第一个程序_python创建新文件
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/174511.html原文链接:https://javaforall.cn
全栈程序员站长
2022/09/27
4930
pycharm创建第一个程序_python创建新文件
如何将文件名称批量导入excel
不给赞赏的话给个赞或者关注下公众号TungHsu吧,不会让你失望的,好玩的数据,免费的软件,学习资料和方法。
用户1315847
2018/07/26
4.7K0
如何将文件名称批量导入excel
Go处理字符串到合法文件名
使用filenamify库 Demo package main import ( "github.com/flytam/filenamify" "fmt" ) func main() { output,err :=filenamify.Filenamify(`<foo/bar>`,filenamify.Options{}) fmt.Println(output,err) // => foo!bar,nil //--- output,err =filenamify.Filen
ACK
2020/02/18
9780
如何删除一个文件名以分号开头的文件
该文讲述了如何删除一个文件名以分号开头的文件。作者通过在Linux上使用VIM编辑器不小心创建了一个文件名以分号开头的文件,尝试使用多种方法删除该文件,包括使用rm命令和转义字符。最后,作者通过在rm命令中添加转义字符成功删除了该文件。
雷大亨
2018/01/01
2.3K0
vscode 设置打开新文件不覆盖前一个窗口
vscode 打开文件时如果会覆盖掉原来窗口中打开的未做修改的文件,非常影响使用体验
Leophen
2020/11/03
6.7K0
vscode 设置打开新文件不覆盖前一个窗口
/var/spool/postfix/maildrop/ 中有大量的文件
今天查看硬盘剩余的容量,发现‘/’目录下占用了大量的空间;可我在这个目录下面没有放什么东西;仔细查看在/var/spool/postfix/maildrop/ 中发现了大量的文件。怎么会有这么多的文件呢,先删除。
双面人
2019/04/10
1.7K0
Python压缩新文件到已有ZIP文件
本文要点在于使用Python标准库zipfile创建压缩文件时,如果使用'a'模式时,可以追加新内容。 from zipfile import ZipFile from os import listdir from os.path import isfile, isdir, join def addFileIntoZipfile(srcDir, fp): #遍历该文件夹中所有文件 for subpath in listdir(srcDir): subpath = join(srcDir,
Python小屋屋主
2018/04/16
1.2K0
Python文件名后缀_python获取目录下所有文件的文件名
使用 os.path.splitext(file)[0] 可获得 文件名 。 使用 os.path.splitext(file)[-1] 可获得以 . 开头的 文件后缀名 。
全栈程序员站长
2022/11/09
4.6K0
当一个文件中有个证书链
公众号是真的好久没更新了,实在抱歉,过年之后到现在终于觉得开始清闲了一下,最近一直在整理在日本时候的照片,主要是最后一个月末赶上了樱花季,得以观赏了樱花盛开的画面,之后跟大家分享一下。
琉璃康康
2022/04/19
5350
两个数组合并成一个数组 请把两个数组 ['A1', 'A2', 'B1', 'B2', 'C1', 'C2', 'D1', 'D2'] 和 ['A', 'B', 'C', 'D'],合并为 ['...
方案1 let arr1 = ['A1', 'A2', 'B1', 'B2', 'C1', 'C2', 'D1', 'D2'] let arr2 = ['A', 'B', 'C', 'D'] arr2 = arr2.map(v => `${v}3`); let arr3=[...arr1, ...arr2].sort().map(v => v.replace('3', '')) console.log(arr3) 方案2 let arr1 = ['A1', 'A2', 'B1', 'B
刘嘿哈
2022/10/25
2K0
算法练习(20) - 将一个交错数据合并为一个一维数组
编程题(20分钟) 将一个交错数据合并为一个一维数组 输入: strJaggedArray[][], 由多个一维数组(长度不定,个数不定)组成的交错数组 输出: strArray[], 由strJaggedArray[r][c]中的元素以"&"为分隔符拼合而成, 是strJaggedArray中数组元素的无重复组合(不考虑顺序)
惊羽-布壳儿
2022/06/15
6140
linux的文件名的长度限制_linux补全文件名
编写本文档,主要目的是为了验证linux下文件数、目录数、文件名长度的各种限制二、文档内容
全栈程序员站长
2022/11/01
5.9K0
Java将两个升序链表合并为一个新的 升序 链表并返回。新链表是通过拼接给定的两个链表的所有节点组成
By CaesarChang 合作: root121toor@gmail.com ~关注我 带你看更多精品技术和面试必备 示例: 输入:1->2->4, 1->3->4 输出:1->1->2->3->4->4 我们设定一个哨兵节点 prehead 和新链表,让prehead等于新链表,我们维护一个 pre,我们需要做的是调整它的 next 指针。然后,我们重复以下过程,直到 l1 或者 l2 指向了 null :如果 l1 当前节点的值小于等于 l2
CaesarChang张旭
2021/01/26
1.6K0
点击加载更多

相似问题

Python -将csv文件合并为一个共同轴

32

熊猫将表合并为两个共同的列

24

将“”改为“。文件名中有"_“

12

将多个文件合并为一个文件,包括文件名。

40

将新文件名传回jquery

11
添加站长 进交流群

领取专属 10元无门槛券

AI混元助手 在线答疑

扫码加入开发者社群
关注 腾讯云开发者公众号

洞察 腾讯核心技术

剖析业界实践案例

扫码关注腾讯云开发者公众号
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文