gpt4 book ai didi

html - 由于我是 Flexbox 的新手,无法获得我需要的东西

转载 作者:太空宇宙 更新时间:2023-11-04 07:55:29 24 4
gpt4 key购买 nike

我正在尝试使用 Flexbox 实现简单的布局结构。我指的是 Guide to Flexbox和我自己学习。下面是我的代码和我想要实现的目标。

.order-history-items {
.order-history-table {

ul {
margin: 0;
padding: 0;
}
li {
list-style-position: inside;
list-style-type: square;
}
.order-shipped-to,
.order-items,
.order-total-price {
width: 33%;
}
.toggle {
cursor: pointer;
display: block;
}
}
}
.js .order-history-table .hidden {
display: none;
}






.orderdetails {
display: flex;
flex-wrap: wrap;

// margin: 0 1%;

h1 {
flex-basis: 100%;
}

h2 {
clear: both;
flex-basis: 100%;
text-align: center;
margin-bottom: 20px;
}

.label {
font-weight: bold;
margin-bottom: .3rem;
margin-top: .3rem;
text-transform: uppercase;
}
.order-shipment-table {
background-color: white;
border: 1px solid ;
border-radius: 5px;
padding: 1em;
}
.order-shipment-details {
.order-shipment-address {
float: right;
}
}
.line-items {
clear: both;
padding-top: 1rem;
.line-item {
padding-bottom: 1rem;
.line-item-details,
.line-item-quantity,
.line-item-price {
display: inline-block;
vertical-align: top;
}
.line-item-quantity,
.line-item-price {
width: 14%;
}
.line-item-details {
width: 70%;
a {
font-size: 1.1rem;
}
}
.line-item-quantity {
text-align: center;
}
.line-item-price {
text-align: right;
}
}
}
flex-basis: 25%;
.order-payment-summary {
@media screen and (min-width: 480px) {
float: right;
}
.label {
font-weight: 800;
font-size: 15px;
margin-bottom: 12px;
}
.order-detail-summary {
.order-key {
text-transform: uppercase;
color: #000;
letter-spacing: 0;
font-size: 12px;
}
.order-value.number--smallest {
font-size: 12px;
font-weight: bold;
letter-spacing: 0px;
color: #000;
}
.order-value.number--large {
color: #000;
letter-spacing: 0;
}
}
}
.order-information {
flex-basis: 100%;
margin-bottom: 30px;
// padding-bottom: .5em;
// padding-top: .5em;
.order-status {
span {
color: #000;
font-weight: 800;
letter-spacing: 0;
text-transform: uppercase;
font-size: smaller;
}
}
.order-date {
span {
color: #000;
font-weight: 800;
letter-spacing: 0;
text-transform: uppercase;
font-size: smaller;
}
}
.label {
color: white;
font-weight: 300;
text-transform: none;
}
.value {
font-weight: 700;
}
.order-number {
font-size: 1.75rem;
}
}
.payment-amount {
.label {
font-weight: normal;
text-transform: none;
}
}
.order-totals-table td {
&:first-child {
padding-right: 5rem;
text-align: left;
}
}
.order-payment-instruments,
.order-billing,
.order-shipment-address
{
flex-basis: 25%;
.label {
font-weight: 800;
font-size: 15px;
}
}
.order-payment-instruments{
padding-left: 84px;
}
.order-billing {
padding-left: 100px;
}
.order-shipment-address
{
padding-left: 120px;
}
.order-shipments {
h2 {
display: flex;
}
}
}
<div class="orderdetails">
<h1>My Order</h1>
<h2 class="order-number">
<span class="label">Order :</span>
<span class="value">STG00004302</span>
</h2>
<div class="order-information">
<div class="order-status">
<span class="label">Order Status:</span>
<span class="value clearfix">Complete</span>
</div>
<div class="order-date">
<span class="label">Order Placed:</span>
<span class="value">10/27/2017 11:02:15 AM</span>
</div>
</div>
<div class="order-payment-summary">
<div class="label">Payment Total</div>
<div class="order-detail-summary">
<div class="order-totals-table">
<div class="order-subtotal order-row">
<div class="order-key">Subtotal</div>
<div class="order-value number--smallest">C$ 21.33</div>
</div>
<div class="order-shipping order-row">
<div class="order-key">
Shipping
</div>
<div class="order-value number--smallest">
C$ 0.00
</div>
</div>
<div class="order-sales-tax order-row">
<div class="order-key">Taxes</div>
<div class="order-value number--smallest">
C$ 2.77
</div>
</div>
<div class="order-total order-row">
<div class="order-key">Order Total:</div>
<div class="order-value number--large">C$ 24.10</div>
</div>
</div>
</div>
</div>
<div class="order-payment-instruments">
<div class="label">
Payment Method
</div>
<div class="payment-type">PayPal</div>
<div class="payment-amount">
<span class="label">Amount:</span>
<span class="value">C$ 24.10</span>
</div>
<!-- END: payment-amount -->
</div>
<div class="order-billing">
<div class="label">Billing Address</div>
<div class="mini-address-name">
Dhon Rocafort
</div>
<div class="mini-address-location">
<address>
1120 N St
<br>Sacramento,
CA
95814-5680<br>
United States
<br>
2122121423
</address>
</div>
</div>
<div class="order-shipment-address">
<div class="label">Shipping To</div>
<div class="mini-address-name">
DihonsKi Rocafort
</div>
<div class="mini-address-location">
<address>
Air Canada Centre
<br>40 Bay St
<br>Toronto,
ON
M5J 2X2<br>
Canada
<br>
2122121423
</address>
</div>
<div class="shipping-method">
<div class="label">Method:</div>
<div class="value">StandardCA</div>
</div>
</div>
</div>

它应该看起来像 this在桌面 View 中:

我关心图像末尾的主要 4 列,它也应该是响应式的。我没有移动 View 的任何细节,但是这 4 列在移动 View 中应该是 2*2。

最佳答案

注意:在整页中打开代码段。

现在,首先请尝试添加尽可能少的代码,因为浏览这么长的 HTML 太难了,您可以删除多余的标记和标签,因为您只需要知道如何使用 flex 对齐

我刚刚调整了对齐方式以匹配您发布的屏幕截图。我将所有 CSS 属性添加为内联样式,并在相应标签上使用 style 属性。

关于 Flexboxes 你需要的一切都在这里 https://css-tricks.com/snippets/css/a-guide-to-flexbox/ .尝试一下,您会很容易掌握它的窍门。

提示 将您的网页分解成组件并将它们包装在 divs 中。使用此设置可以更容易地控制对齐方式,尤其是 flexboxes

html, body {
height: 100%;
}
.order-history-items {
.order-history-table {

ul {
margin: 0;
padding: 0;
}
li {
list-style-position: inside;
list-style-type: square;
}
.order-shipped-to,
.order-items,
.order-total-price {
width: 33%;
}
.toggle {
cursor: pointer;
display: block;
}
}
}
.js .order-history-table .hidden {
display: none;
}






.orderdetails {
display: flex;

flex-wrap: wrap;

// margin: 0 1%;

h1 {
flex-basis: 100%;
}

h2 {
clear: both;
flex-basis: 100%;
text-align: center;
margin-bottom: 20px;
}

.label {
font-weight: bold;
margin-bottom: .3rem;
margin-top: .3rem;
text-transform: uppercase;
}
.order-shipment-table {
background-color: white;
border: 1px solid ;
border-radius: 5px;
padding: 1em;
}
.order-shipment-details {
.order-shipment-address {
float: right;
}
}
.line-items {
clear: both;
padding-top: 1rem;
.line-item {
padding-bottom: 1rem;
.line-item-details,
.line-item-quantity,
.line-item-price {
display: inline-block;
vertical-align: top;
}
.line-item-quantity,
.line-item-price {
width: 14%;
}
.line-item-details {
width: 70%;
a {
font-size: 1.1rem;
}
}
.line-item-quantity {
text-align: center;
}
.line-item-price {
text-align: right;
}
}
}
flex-basis: 25%;
.order-payment-summary {
@media screen and (min-width: 480px) {
float: right;
}
.label {
font-weight: 800;
font-size: 15px;
margin-bottom: 12px;
}
.order-detail-summary {
.order-key {
text-transform: uppercase;
color: #000;
letter-spacing: 0;
font-size: 12px;
}
.order-value.number--smallest {
font-size: 12px;
font-weight: bold;
letter-spacing: 0px;
color: #000;
}
.order-value.number--large {
color: #000;
letter-spacing: 0;
}
}
}
.order-information {
flex-basis: 100%;
margin-bottom: 30px;
// padding-bottom: .5em;
// padding-top: .5em;
.order-status {
span {
color: #000;
font-weight: 800;
letter-spacing: 0;
text-transform: uppercase;
font-size: smaller;
}
}
.order-date {
span {
color: #000;
font-weight: 800;
letter-spacing: 0;
text-transform: uppercase;
font-size: smaller;
}
}
.label {
color: white;
font-weight: 300;
text-transform: none;
}
.value {
font-weight: 700;
}
.order-number {
font-size: 1.75rem;
}
}
.payment-amount {
.label {
font-weight: normal;
text-transform: none;
}
}
.order-totals-table td {
&:first-child {
padding-right: 5rem;
text-align: left;
}
}
.order-payment-instruments,
.order-billing,
.order-shipment-address
{
flex-basis: 25%;
.label {
font-weight: 800;
font-size: 15px;
}
}
.order-payment-instruments{
padding-left: 84px;
}
.order-billing {
padding-left: 100px;
}
.order-shipment-address
{
padding-left: 120px;
}
.order-shipments {
h2 {
display: flex;
}
}
}
<div class="orderdetails" style="display: flex; flex-direction: column; height: 50%">
<h1 style="margin: auto;">My Order</h1>
<h2 class="order-number" style="margin: auto;">
<span class="label">Order :</span>
<span class="value">STG00004302</span>
</h2>
<div class="order-information" style="margin: 10px;">
<div class="order-status">
<span class="label">Order Status:</span>
<span class="value clearfix">Complete</span>
</div>
<div class="order-date">
<span class="label">Order Placed:</span>
<span class="value">10/27/2017 11:02:15 AM</span>
</div>
</div>
<div style="display: flex; flex-direction: row; justify-content: space-around;">
<div class="order-payment-summary">
<div class="label">Payment Total</div>
<div class="order-detail-summary">
<div class="order-totals-table">
<div class="order-subtotal order-row">
<div class="order-key">Subtotal</div>
<div class="order-value number--smallest">C$ 21.33</div>
</div>
<div class="order-shipping order-row">
<div class="order-key">
Shipping
</div>
<div class="order-value number--smallest">
C$ 0.00
</div>
</div>
<div class="order-sales-tax order-row">
<div class="order-key">Taxes</div>
<div class="order-value number--smallest">
C$ 2.77
</div>
</div>
<div class="order-total order-row">
<div class="order-key">Order Total:</div>
<div class="order-value number--large">C$ 24.10</div>
</div>
</div>
</div>
</div>
<div class="order-payment-instruments">
<div class="label">
Payment Method
</div>
<div class="payment-type">PayPal</div>
<div class="payment-amount">
<span class="label">Amount:</span>
<span class="value">C$ 24.10</span>
</div>
<!-- END: payment-amount -->
</div>
<div class="order-billing">
<div class="label">Billing Address</div>
<div class="mini-address-name">
Dhon Rocafort
</div>
<div class="mini-address-location">
<address>
1120 N St
<br>Sacramento,
CA
95814-5680<br>
United States
<br>
2122121423
</address>
</div>
</div>
<div class="order-shipment-address">
<div class="label">Shipping To</div>
<div class="mini-address-name">
DihonsKi Rocafort
</div>
<div class="mini-address-location">
<address>
Air Canada Centre
<br>40 Bay St
<br>Toronto,
ON
M5J 2X2<br>
Canada
<br>
2122121423
</address>
</div>
<div class="shipping-method">
<div class="label">Method:</div>
<div class="value">StandardCA</div>
</div>
</div>
</div>
</div>

关于html - 由于我是 Flexbox 的新手,无法获得我需要的东西,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47374095/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com