css 用照片定位表格块和文本块

amrnrhlw  于 2023-08-09  发布在  其他
关注(0)|答案(2)|浏览(95)

我明天有个任务要交,要做一个版面设计的部分。现在,我刚刚开始学习,并不真正了解在全视图中该做什么。我在这件事上坐了这么久,我什么也不明白。我需要把表单放在右边,文本放在左边,中间有一个188像素宽的缩进。我知道这个要求不符合标准,但我非常感谢任何帮助和解释。- 谢谢-谢谢
我附上了一个链接到CodePen和一些截图。先谢谢你了。

:root {
  /* Colors */
  --black-cl: #11131f;
  --dark-cl: #1f212d;
  --light-grn-cl: #93abae;
  --white-cl: #f6f5ef;
  --hover-cl: #88b3b9;
  --grey-cl: rgba(246, 245, 239, 0.5);
  --linear-gradient: linear-gradient(#bec7c2 0%, #a1b5ba 100%);
  /* The main number of elements in Flexbox grid */
  --items: 3;
  /* The main gap indent in Flexbox grid */
  --indent: 16px;
  /* Transition settings */
  --main-transition-function: 250ms cubic-bezier(0.4, 0, 0.2, 1);

  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
}

.rent-yacht-heading {
  width: 282px;
  height: 132px;
  color: var(--white-cl);
  font-family: DM Sans;
  font-size: 60px;
  font-style: normal;
  font-weight: 500;
  line-height: 66px;
  letter-spacing: -2.7px;
  margin-bottom: 64px;
}

.rent-yacht-form-container,
.rent-yacht-textarea-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 28px;
}

.rent-yacht-input {
  background-color: inherit;
  border: 0;
  outline: 0;
  border-bottom: 1px solid var(--white-cl);
  width: 443px;
  height: 35px;
  color: var(--white-cl);
}

.rent-yacht-input::placeholder,
.rent-yacht-textarea::placeholder {
  font-family: DM Sans;
  font-size: 16px;
  font-style: normal;
  font-weight: 500;
  line-height: 19.2px;
  letter-spacing: -0.72px;
  color: var(--white-cl);
}

.rent-yacht-textarea {
  background-color: inherit;
  width: 443px;
  height: 77px;
  resize: none;
  border: 0;
  outline: 0;
  border-bottom: 1px solid var(--white-cl);
  color: var(--white-cl);
}

.rent-yacht-send-button {
  width: 132px;
  height: 48px;
  display: flex;
  padding: 14px 28px;
  justify-content: center;
  align-items: center;
  border-radius: 60px;
  border: 1px solid var(--white-cl);
  font-family: DM Sans;
  font-size: 18px;
  font-style: normal;
  font-weight: 700;
  line-height: 20px;
  letter-spacing: -0.81px;
  margin-top: 64px;
  color: var(--main-white-cl);
  background-color: inherit;
}

.send-arrows-icon {
  fill: var(--white, #f6f5ef);
  margin-left: 16px;
}

.rent-yacht-image,
.rent-yacht-form-container {
  width: calc(50% - 188px);
}

个字符
x1c 0d1x的数据


wwwo4jvm

wwwo4jvm1#

下面是你需要做的:
调整“rent-yacht-image”和“rent-yacht-form-container”类的CSS样式,使其宽度为50%减去188像素的缩进。这将确保表单和文本各占容器的一半。
添加CSS样式以在“rent-yacht-image”和“rent-yacht-form-container”之间创建间隙。我们将为“rent-yacht-image”类使用“margin-right”属性。
确保“rent-yacht-image”和“rent-yacht-form-container”元素使用“display:flex”属性。

.rent-yacht-image,
.rent-yacht-form-container {
  width: calc(50% - 188px);
}

.rent-yacht-image {
  margin-right: 188px; /* Add a gap between the image and the form */
}

.rent-yacht-section {
  display: flex; /* Ensure the elements are displayed side by side */
}

.rent-yacht-block {
  display: flex;
}

.rent-yacht-form-container,
.rent-yacht-textarea-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 28px;
}

字符串

whitzsjs

whitzsjs2#

我必须做出的改变:

/* .rent-yacht-image,
.rent-yacht-form-container {
width: calc(50% - 188px);
} */

.rent-yacht-block{
    display: flex;
    justify-content: center;
}

.rent-yacht-image{
    margin-right: 188px;
}

字符串
我还临时设置了一个正文背景,使内容更清晰可见。你可以移除它。

body{
    background: grey
}

:root {
/* Colors */
--black-cl: #11131f;
--dark-cl: #1f212d;
--light-grn-cl: #93abae;
--white-cl: #f6f5ef;
--hover-cl: #88b3b9;
--grey-cl: rgba(246, 245, 239, 0.5);
--linear-gradient: linear-gradient(#bec7c2 0%, #a1b5ba 100%);
/* The main number of elements in Flexbox grid */
--items: 3;
/* The main gap indent in Flexbox grid */
--indent: 16px;
/* Transition settings */
--main-transition-function: 250ms cubic-bezier(0.4, 0, 0.2, 1);

font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-text-size-adjust: 100%;
}
.rent-yacht-heading {
width: 282px;
height: 132px;
color: var(--white-cl);
font-family: DM Sans;
font-size: 60px;
font-style: normal;
font-weight: 500;
line-height: 66px;
letter-spacing: -2.7px;
margin-bottom: 64px;
}
.rent-yacht-form-container,
.rent-yacht-textarea-container {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 28px;
}
.rent-yacht-input {
background-color: inherit;
border: 0;
outline: 0;
border-bottom: 1px solid var(--white-cl);
width: 443px;
height: 35px;
color: var(--white-cl);
}
.rent-yacht-input::placeholder,
.rent-yacht-textarea::placeholder {
font-family: DM Sans;
font-size: 16px;
font-style: normal;
font-weight: 500;
line-height: 19.2px;
letter-spacing: -0.72px;
color: var(--white-cl);
}
.rent-yacht-textarea {
background-color: inherit;
width: 443px;
height: 77px;
resize: none;
border: 0;
outline: 0;
border-bottom: 1px solid var(--white-cl);
color: var(--white-cl);
}
.rent-yacht-send-button {
width: 132px;
height: 48px;
display: flex;
padding: 14px 28px;
justify-content: center;
align-items: center;
border-radius: 60px;
border: 1px solid var(--white-cl);
font-family: DM Sans;
font-size: 18px;
font-style: normal;
font-weight: 700;
line-height: 20px;
letter-spacing: -0.81px;
margin-top: 64px;
color: var(--main-white-cl);
background-color: inherit;
}
.send-arrows-icon {
fill: var(--white, #f6f5ef);
margin-left: 16px;
}
/* .rent-yacht-image,
.rent-yacht-form-container {
width: calc(50% - 188px);
} */

.rent-yacht-block{
    display: flex;
    justify-content: center;
}

.rent-yacht-image{
    margin-right: 188px;
}
<section class="rent-yacht-section">
    <div class="rent-yacht-block container">
      <div class="rent-yacht-image">
        <h3 class="rent-yacht-heading">Rent a yacht now</h3>
        <img src="../img/rent/img-rent-yacht-01@1x.jpg" alt="Rent yacht now" class="rent-yacht-img" />
      </div>
      <div class="rent-yacht-form-container">
        <form class="rent-yacht-form">
          <div class="rent-yacht-form-container">
            <label for="user-name" class="rent-yacht-input-label"></label>
            <div class="rent-yacht-input-container">
              <input type="text" placeholder="Full Name" name="user-name" id="user-name" class="rent-yacht-input" />
            </div>
          </div>
          <div class="rent-yacht-form-container">
            <label for="user-email" class="rent-yacht-input-label"></label>
            <div class="rent-yacht-input-container">
              <input type="email" placeholder="Email" class="rent-yacht-input" />
            </div>
          </div>
          <div class="rent-yacht-form-container">
            <label for="user-phone" class="rent-yacht-input-label"></label>
            <div class="rent-yacht-input-container">
              <input type="tel" placeholder="Phone Number" class="rent-yacht-input" />
            </div>
          </div>
          <div class="rent-yacht-textarea-container">
            <label for="user-comment" class="rent-yacht-input-label"></label>
            <textarea
              name="user-comment"
              id="user-comment"
              cols="30"
              rows="10"
              placeholder="Comment"
              class="rent-yacht-textarea"
            ></textarea>
          </div>
          <button class="rent-yacht-send-button" type="submit">
            Send<svg class="send-arrows-icon" width="18" height="8">
              <use href="../img/icons.svg#icon-arrow-right"></use>
            </svg>
          </button>
        </form>
      </div>
    </div>
</section>

的数据

相关问题