我有这张图片,我需要回复。
我已经完成了大部分代码,但是在做黑匣子时遇到了一些麻烦。
它必须是:
 -在“ redbox”顶部
 -在“ bluebox”后面
 -在“ blueinbox”顶部

html - 黑匣子姿势练习-LMLPHP



body {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    margin:0 !important;
    width: 100% !important;
    -webkit-text-size-adjust: 100% !important;
    -ms-text-size-adjust: 100% !important;
    -webkit-font-smoothing: antialiased !important;
}
.container {
    background-color: #e1e1e1;
    height: 200px;
    width: 400px;
    border: 0;
    margin: auto;
    display: table;
    margin-top: 20px;
    position: relative;
}
.redbox {
    background-color: #fff;
    height: 120px;
    width: 120px;
    margin: 20px 20px 0 0;
    display: table;
    right: 0;
    border-style: solid;
    border-width: 1px;
    border-color: red;
    border-radius: 5px;
    position: absolute;
}
.bluebox {
    background-color: #fff;
    height: 120px;
    width: 120px;
    margin: 60px 60px 0 0;
    display: table;
    right: 0;
    border-style: solid;
    border-width: 1px;
    border-color: blue;
    position: absolute;
    border-left-style: dashed;
}
.blueinbox {
    background-color: #00aeef;
    height: 80px;
    width: 80px;
    margin: 20px 20px 0 0;
    float: right;
}
.ninja {
    color: #fff;
    font-family: "Open Sans", Arial, sans-serif;
    letter-spacing: 2px;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-right: -50%;
    transform: translate(-50%, -50%)
}

<body>
    <div class="container">
        <div class="redbox">
        </div>
        <div class="bluebox">
            <div class="blueinbox">
                <div class="ninja">
                    <p>NINJA!</p>
                </div>
            </div>
        </div>
    </div>

</body>

最佳答案

做完了



body {
	font: 500 16px 'Open Sans', Arial, sans-serif;
	color: #fff;
}

.container {
	position: relative;
	max-width: 400px;
	height: 200px;
	margin: 2rem auto;
	border: 1px solid #000;
	background-color: #eee;
}

.box-red, .box-blue-light, .box-blue-dark, .box-black {
	position: absolute;
}

.box-red {
	top: 20px;
	right: 20px;
	width: 120px;
	height: 120px;
	border: 1px solid red;
	border-radius: 5px;
}

.box-black {
	top: 40px;
	right: 40px;
	width: 60px;
	height: 60px;
	background-color: #000;
}

.box-blue-light {
	top: 80px;
	right: 80px;
	width: 80px;
	height: 80px;
	background-color: #05adeb;
}
.box-blue-light::before {
	content: "";
	position: absolute;
	right: 0;
	width: 20px;
	height: 20px;
	background-color: #000;
}
.box-blue-light h5 {
	margin-top: 2rem;
	font: 500 1rem 'Open Sans';
	letter-spacing: 2px;
	text-align: center;
}

.box-blue-dark {
	top: 60px;
	right: 60px;
	width: 120px;
	height: 120px;
	border: 1px solid blue;
	border-left-style: dashed;
	background: #fff url("https://media1.giphy.com/media/fLg3MEWdgH5Ti/200.gif");
}
.box-blue-dark::after {
	content: "";
	position: absolute;
	width: 100%;
	height: 100%;
	background-color: rgba(170,50,90,.25)
}

<body>
	<div class="container">
		<div class="box-red"></div>
		<div class="box-black"></div>
		<div class="box-blue-dark"></div>
		<div class="box-blue-light"><h5>NINJA!<h5></div>
	</div>
</body>

09-19 07:40