简体   繁体   English

对齐 flexbox 中的文本

[英]Aligning text in a flexbox

We were asked to design and code a website for high school lesson.我们被要求为高中课程设计和编码一个网站。

I've designed it in figma and then started coding (more like suffering ahahha) in replit.我在 figma 中设计了它,然后在 replit 中开始编码(更像是痛苦啊哈哈)。 I designed both the header and the main text to be at the same level in figma.我将 header 和正文都设计为在 figma 中处于同一水平。 , but when i started writing the code, the paragraph text is slightly shifted to the left comparing with the header. ,但是当我开始编写代码时,与 header 相比,段落文本略微向左移动。 I've tried to align them using align items and margings and stuff like that, though i dont fully understand how they work yet tbh.我尝试使用对齐项目和边距之类的东西来对齐它们,尽管我还不完全了解它们是如何工作的。 If anyone knows what to do, and is willing to spend a little of their time looking into the code,如果有人知道该做什么,并且愿意花一点时间研究代码,

i will be very thankful!!!!!!!!!我会很感激的!!!!!!!!!

This is a non-comercial high school homework task.这是一项非商业性的高中家庭作业。

if you need more details about the project, just ask:)如果您需要有关该项目的更多详细信息,请询问:)

the css code: css 代码:

   .logo2{
  padding-left: 65%;}
h2{
 display: flex;
font-family: 'Annie Use Your Telescope', cursive;
font-style: normal;
font-weight: normal;
text-align: center;
font-size: 63px;
color: #000000;
text-shadow: 4px 2px 0.5px #b4deb3, 0 0 1em #b4deb3;
}

.container2 { display: flex; flex-direction: column; padding: 8%;
  }
  .container2 div{
  border: 1px solid greenyellow; padding: 10px;
}
  .image1{display: flex; flex-direction: row; } 
   .imag1, .text1 {flex:50%;}
   .imag1, .imag2, .imag3 {display: flex; justify-content: center; align-items: center;}
  .image2 { display: flex; flex-direction: row;} 
   .imag2, .text2 {flex:50%}
  .image3 { display: flex; flex-direction:row;} 
   .imag3, .text3 {flex:50%}
   .text1, .text2, .text3 {text-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25); display: flex; align-items: left; justify-content: left; text-align: left; flex-direction: column;}
   
   .but1 {text-align: center; line-height: 1em }

 
.gs {
font-family: Athiti;
font-style: normal;
font-weight: normal;
font-size: 40px;
line-height: 160.5%;
}
.onedayticket {
  padding-left: 15%;
  font-family: Athiti;
font-style: normal;
font-weight: normal;
font-size: 28px;
line-height: 160.5%;

align-items: left;

color: #000000;

text-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);}

.but1 {filter: drop-shadow(8px 9px 14px rgba(254, 193, 233, 0.71)); width: 286.79px;
height: 70px;
left: 1026px;
top: 2496px;

background: rgba(255, 255, 255, 0.68);
border: 0.5px solid #000000;
box-sizing: border-box;
box-shadow: 0px 4px 4px #B4DEB3;
font-family: Athiti;
font-style: normal;
font-weight: normal;
font-size: 28px;
line-height: 45px;
display: flex;
align-items: center;
text-align: center;
color: #000000;}

the html code: html 代码:

<section class="third" id="shop">
      <div class = "container">
      <div class ="container2">
        <div class="image1">
         <div class="imag1">
          <img class= "tickets" src="tck/green.png">
         </div>
         <div class="text1">
          <header class="gs"> Green submarine </header>
          <p class="onedayticket"> The one-day ticket. Lets you expore our music festival for a single day of you choice</p>
          <button class="but1"> Buy ticket </button>
         </div>
        </div>
        <div class="image2">
         <div class="imag2">
          <img class= "tickets2" src="tck/blue.png">
         </div>
         <div class="text2"> 
          <header1 class="gs"> The Eggman </header1>
          <p class="onedayticket"> The three-day ticket. Enjoy any three days of the festival with this ticket</p>
          <button class="but1"> Buy ticket </button>
         </div>
        </div>
        <div class="image3">
         <div class="imag3">
          <img class= "tickets3" src="tck/pink.png">
         </div>
         <div class="text3"> 
          <header1 class="gs"> The Walrus </header1>
          <p class="onedayticket"> Expanded VIP ticket.
During our week-long festival all the concerts are open for you at any time. </p>
<button class="but1"> Buy ticket </button>
         </div>
        </div>
      </div>
      </div>
    </section> 

I'm not sure if this is what you're looking for.我不确定这是否是你要找的。 Remove padding-left: 15%;移除padding-left: 15%; on onedayticket because this is pushing the text to the right.onedayticket上,因为这会将文本推到右侧。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM