在图像上正确放置文本{CSS HTML}

SapirFrontEnd

[如何在图像上正确放置文字?我有三个文本块,我想将它们放置在图像的同一行上,但是我很努力:(

#banner {
        
        justify-content: center;
        height: 600px;
        margin-top: 100px;
        margin-left: 10%; }
    
    .banner-text {
        color: white;
        justify-content: center;
        justify-content: space-around;
        text-align: center;
        display: inline-block;
        position: absolute;
        flex-direction: column; }
    
    /*DownTown*/ 
     .flex-text {

       background-color: grey;    
       text-align: center;
     }

html

 <div id="banner"><img src="2525.jpeg">
        
           
           <div class="banner-text">
            <div class="flex-text text1">
               <h1><b>DownTown</b> 384 West 4th St Suite 108</h1>
            <div class="flex-text text2">
                <h1><b>East Bayside</b>  3433 Phisherman Avenue </h1>
            <div class="flex-text text3">
                <h1><b>Oakdale</b> 515 Crecent avenue Second Floor </h1>    
            
            </div>    
                </div>
                </div>
                </div>
            </div>    

这是它的外观在此处输入图片说明] 2

那就是我的做法-_- 在此处输入图片说明

优素福

您的html标记不正确,而不是将图像添加为中的img元素,而是#banner使用CSS将图像添加为背景图像。这样,您就不需要在文本上放置文本的绝对位置。之后,使用flexbox对齐元素。

#banner {
  background-image: url(https://picsum.photos/500);
  background-repeat: no-repeat;
  background-size: cover;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.banner-text {
  color: white;
  justify-content: space-around;
  display: flex;
  width: 100%;
  flex-wrap: wrap;
}

.flex-text {
  background-color: #222;
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: space-between;
  height: 180px;
  padding: 20px;
  width: 200px;
  margin: 5px;
}

h1 {
  margin: 0;
}
<div id="banner">

  <div class="banner-text">
    <div class="flex-text text1">
      <h1>DownTown</h1>
      <span>384 West 4th St</span>
      <span>Suite 108</span>
      <span>Portland, Maine</span>
    </div>
    <div class="flex-text text1">
      <h1>DownTown</h1>
      <span>384 West 4th St</span>
      <span>Suite 108</span>
      <span>Portland, Maine</span>
    </div>
    <div class="flex-text text1">
      <h1>DownTown</h1>
      <span>384 West 4th St</span>
      <span>Suite 108</span>
      <span>Portland, Maine</span>
    </div>
  </div>
  
</div>

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

使用HTML和CSS在图像上放置文本

来自分类Dev

正确放置旋转的文本(字母间距/ html5 / CSS)

来自分类Dev

无法使用 css/html 并排放置图像和文本

来自分类Dev

无法在 html 中的图像上放置文本

来自分类Dev

HTML / CSS:文本覆盖在背景图像上

来自分类Dev

HTML CSS-将一个图像放置在另一个图像上

来自分类Dev

如何使用CSS在不同大小的图像上放置文本?

来自分类Dev

CSS在同一行上放置文本和图像

来自分类Dev

如何使用HTML和CSS并排放置图像和文本?

来自分类Dev

如何在CSS上放置HTML代码

来自分类Dev

如何在html和css的图像链接轮廓上放置颜色?

来自分类Dev

CSS放置HTML元素

来自分类Dev

图像不在正确的位置简单的 HTML CSS

来自分类Dev

如何使用HTML和CSS正确格式化和分割图像使其位于文本的右侧

来自分类Dev

html&css-以正确方式对齐的图像和文本不起作用

来自分类Dev

如何使文本浮动在图像HTML CSS的顶部

来自分类Dev

图像 HTML CSS 旁边的浮动文本

来自分类Dev

如何使用CSS正确放置图像

来自分类Dev

html css中的图像上的文字

来自分类Dev

在移动CSS / HTML上加载图像

来自分类Dev

如何使用css / html并排放置图像数组

来自分类Dev

使用HTML和CSS将图像放置到Circle中

来自分类Dev

在图像HTML和CSS的中心放置一种边框

来自分类Dev

使用HTML和CSS将图像放置到Circle中

来自分类Dev

HTML / CSS裁剪图像

来自分类Dev

图像对齐 HTML CSS

来自分类Dev

图像滑块 html css

来自分类Dev

HTML,CSS,文本方向

来自分类Dev

节文本在html / css上通过页脚