css - 如何在小型设备的中间列中设置 div 位置以使此发票标题具有响应性

标签 css

低于 767,我希望中间的列日期、截止日期和 ID 应该堆叠在一起(截止日期、日期,然后是 id 或日期、截止日期和 id,其中截止日期和 id 在日期列下方在中间)这意味着应该有 3 列,而不是宽度超过 767 的五列。 如何使用 css 实现这一点。如果有什么更好的方法可以使它响应迅速,请分享。

我是否应该为移动设备创建一个单独的行并将其隐藏在较大的设备上。 或者可以使用同一行并使中间的三个 div 一个接一个地堆叠。

@media only screen and (max-width: 767px) {
}

<!DOCTYPE html>
<html>
<head>
	<title></title>
</head>
<style type="text/css">
	.container {
		width: 80%;
		margin: 0 auto;
		border: 1px solid grey;
		height: 100%;
	}
	.invo-to,.due,.date,.id {
		float: left;
	}
	.invo-from {
		float: right;
		text-align: right;
	}
	.invo-to {
		width: 25%;
	}
	.due,.date,.id {
		width: 16%;
	}
	.invo-from {
		width: 25%;
	}
	h6 {
		font-size: 18px;
		margin: 0;
	}
	p {
		font-size: 16px;
	}
</style>
<body>
<div class="container">
<div class="invo-to">
	<h6>Invoice To</h6>
	<p>John Mason</p>
	<p>john@gmail.com</p>
</div>
<div class="due">
	<h6>Due Date</h6>
	<p>11-05-1990</p>
</div>
<div class="date">
	<h6>Date</h6>
	<p>11-05-1990</p>
</div>
<div class="id">
	<h6>Invoice Id</h6>
	<p>66</p>
</div>
<div class="invo-from">
	<h6>Invoice From</h6>
	<p>Xskd Lksdds di LTD</p>
	<p>lksdds@gmail.com</p>
</div>
</div>
</body>
</html>

最佳答案

替换这段代码


<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<style type="text/css">
    .container {
        width: 80%;
        margin: 0 auto;
        border: 1px solid grey;
        padding: 15px;
    }
    .details {
        display: flex;
    }
    .invo-to {
        width: 15%;
    }
    .invo-from {
        width: 20%;
    }
    .due_date_id {
        width: 65%;
        display: flex;
        justify-content: space-around;
    }
    h6 {
        font-size: 18px;
        margin: 0;
    }
    p {
        font-size: 16px;
    }
    @media screen and (max-width: 767px) {
    .container {
        width:100%;
    }
    .due_date_id {
        width: 33%;
        display: flex;
        flex-direction: column;
    }
    .invo-to {
        width: 33%;
    }
    .invo-from {
        width: 33%;
    }
    }
</style>
<body>
<div class="container">
    <div class="details">
        <div class="invo-to">
            <h6>Invoice To</h6>
            <p>John Mason</p>
            <p>john@gmail.com</p>
        </div>
        <div class="due_date_id">
            <div class="due">
                <h6>Due Date</h6>
                <p>11-05-1990</p>
            </div>
            <div class="date">
                <h6>Date</h6>
                <p>11-05-1990</p>
            </div>
            <div class="id">
                <h6>Invoice Id</h6>
                <p>66</p>
            </div>
        </div>
        <div class="invo-from">
            <h6>Invoice From</h6>
            <p>Xskd Lksdds di LTD</p>
            <p>lksdds@gmail.com</p>
        </div>
    </div>
</div>
</body>
</html>

关于css - 如何在小型设备的中间列中设置 div 位置以使此发票标题具有响应性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56195764/

相关文章:

html - 删除网站上的 CSS 空间

html - CSS - 响应问题

html - 使用 HTML & CSS3 : How to extend the borders of the inner table vertically, 使其触及外表

css - 如何改变一个窗体的背景,使它看起来像两个窗体?

css - 使用 CSS 更改带有嵌套输入字段的字段集的背景颜色

css - 导航栏上的可缩放宽度

css - 不清楚位置 : relative in CSS

jquery - 根据复选框状态修改父类

CSS 不适用于 Razor 页面中的 asp-page 标签

css - 文本垂直对齐的图标