繁体   English   中英

如何在我的CSS中正确调整边距?

[英]How can I properly adjust margins in my css?

我有一个简单的分布式系统项目,旨在开发航空公司的预订和购买系统。 在这个项目中,主要目标是实现适当的功能,而不是实现最佳的可视性。 但是,由于我缺乏网页设计领域的经验,我确实遇到了基本的问题。 任何您的兴趣将不胜感激!

在我的主页上,我尝试绘制飞机布局,但问题是边缘。 我无法正确安排飞机边界之间的座位。

演示我丑陋的home.php:
在此输入图像描述

我home.php的架构:

<div class="content">
...
   <div class="airplane">
   ...
      <div class="cockpit">...</div>

      <ol class="fuselage">
         <li class="row row--1">
            <ol class="seats">
               <li class="seat">...</li>
            </ol>
         </ol>
     </ol>
  </div>
</div>

这是我的CSS代码:

div.content
{
  margin-left: 200px;
  padding: 1px 16px;
  height: auto;             
}

@media screen and (max-width: 700px)
{
  .sidebar
  {
    width: 100%;
    height: auto;
    position: relative;
  }
  .sidebar a
  {
    float: left;
  }
  div.content
  {
    margin-left: 0;
  }
}

@media screen and (max-width: 400px)
{
  .sidebar a
  {
    text-align: center;
    float: none;
  }
}

.airplane
{
  margin: 10px auto;
  max-width: 500px;
  position: relative;
  margin-left: 25px;
}

.cockpit
{
  margin-left: 25px;
  height: 250px;
  position: relative;
  overflow:hidden;
  text-align: center;
  border-bottom: 5px solid #993333;
}

.cockpit:before
{
  content: "";
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  height: 500px;
  width: 98%;                         
  border-radius: 50%;
  border-right: 5px solid #993333;
  border-left: 5px solid #993333;
}

.cockpit h2 {
  width: 70%;                         
  margin: 120px auto 35px auto;       
}

.fuselage
{
  margin-left: 25px;                  
  border-right: 5px solid #993333;
  border-left: 5px solid #993333;
}

ol
{
  list-style :none;
  padding: 0;
  margin: 0;
}

.row
{

}

.seats
{
  margin-left: 25px;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: flex-start;
  margin: 0 5px 0 250px;                
}

.seat {
  display: flex;
  flex: 0 0 25.28571428571429%;
  padding: 5px;
  position: relative;
}
.seat:nth-child(3) {
  margin-right: 15.28571428571429%;     
}

.seat input[type=checkbox] {
  position: absolute;
  opacity: 0;
}
.seat input[type=checkbox]:checked + label {
  background: yellow;
}
.seat input[type=checkbox]:disabled + label {
  background: #dddddd;
  text-indent: -9999px;
  overflow: hidden;
}
.seat input[type=checkbox]:disabled + label:after {
  content: "X";
  text-indent: 0;
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translate(-50%, 0%);
}
.seat input[type=checkbox]:disabled + label:hover {
  box-shadow: none;
  cursor: not-allowed;
}
.seat label {
  display: block;
  position: relative;
  width: 70%;
  text-align: center;
  font-size: 11px;
  font-weight: bold;
  line-height: 1.5rem;
  padding: 4px 0px;
  background: green;
  border-radius: 5px;
}
.seat label:before {
  content: "";
  position: absolute;
  width: 75%;
  height: 75%;
  top: 1px;
  left: 50%;
  transform: translate(-50%, 0%);
  background: rgba(255, 255, 255, 0.4);
  border-radius: 3px;
}
.seat label:hover {
  cursor: pointer;
  box-shadow: 0 0 0px 2px #5C6AFF;
}

您可以在代码的以下部分中修复剩余边距:

.seat {
    display: flex;
    flex: 0 0 25.28571428571429%;
    padding: 5px;
    margin-left: -50px;    // lay seats over plane borders
    position: relative;
}

通过此自定义,您可以将座位放在飞机上。 此值仅用于演示目的,并作为示例

你能不能试试下面的座位;

.seats
{
  margin-left: 25px;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: flex-end;
  margin: 0 5px 0 200px;              
}

暂无
暂无

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

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