html - 图像不会彼此相邻显示

标签 html css

我试图让我的两张图片紧挨着显示。目前他们一直在彼此下面。我已经搜索了一些帮助,但所有这些都使图像保持不变。我希望你们中的一些人能够理解 html 和 css 并帮助我解决这个问题。

图像在它们各自的表单中,并且两个图像都具有一些样式,因此它们具有悬停效果。

.container {
    position: relative;
    width: 400px;
    height: 400px;
    display: inline-block;
}

.image {
    width: 400px;
    height: 400px;
}

.overlay {
    position: absolute;
    transition: all .3s ease;
    opacity: 0;
    background-color: #eee;
    pointer-events: none;
}

.container:hover .overlay{
    opacity: 1;
}

.text {
    color: white;
    font-family: sans-serif;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    font-size: 20px;
}

.overlayFade {
    height: 100%;
    width: 100%;
    top: 0;
    left: 0;
    background-color: #39598cab;
}

.container:hover .overlayFade{
    width: 100%;
}
    <center>
        <form action="FrontController" method="post">
            <h2>Vælg hvilken tag type du ønsker</h2>
            <div class="container">                
                <div class="overlay overlayFade">
                    <div class="text">
                        <h1>Spidst tag</h1>
                        Quick-byg carport med spidst tag
                    </div>
                </div>
                <input type="hidden" name="command" value="PointedRoof">
               <input type="image" src="./IMAGES/spidsTag.jpg" class="image" value="Spidst Tag">
            </div>
        </form></center>
        
        
    <center>
        <form action="FrontController" method="post">
            <div class="container">
                <div class="overlay overlayFade">
                    <div class="text">
                        <h1>Fladt tag</h1>
                        Quick-byg carport med fladt tag
                    </div>
                </div>
                <input type="hidden" name="command" value="FlatRoof">
                <input type="image" src="./IMAGES/fladtTag.png" class="image" value="Fladt tag">
            </div>
        </form>
    </center>

最佳答案

由于 block 属性,图像显示在彼此之下。 因为 Center 标记默认具有 block 属性。 只需在您的样式表中添加下面的 css

center{display: inline-block;}

关于html - 图像不会彼此相邻显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53459623/

相关文章:

html - 如何将表格数据元素本身置于行的中心?

css - 嵌套文章 "spill over"节

jquery - 为什么应用 CSS3 动画后背景文字的字体会发生变化?

php - Apache 返回没有样式的页面,只有文本和图像

jquery - 当侧边栏打开时, body 会向左推

html - 网站上的作品引用页面,除第一行外的所有内容均缩进

Javascript图像上传和显示

css - 为什么我的重力表单复选框和标签不对齐?

php - 下拉搜索列表无法将变量设置为等于所选选项

html - 我可以在 css 中使用 device-width 来获取 css 本身的浏览器宽度吗?