我想像标题一样在每个图标的正下方放置文本。我不太确定要使用什么功能。我尝试使用span和display block,但文本最终出现在怪异的地方,并且图标移动了。我将在每个文本下方插入一小段文本,包括“ ABOUT”之类的标题。另外,我还没有将图片放在css图标的背景中。
html,
body {
font-family: Bahnschrift;
font-size: 13;
}
h1,h2,h3{margin: auto; text-align:center;}
.wrap {
max-width: 1100px;
margin: 0 auto;
}
header {
width: 100%;
height: 108px;
background-color: #001e22;
}
header .wrap > img {
margin-top: 17px;
}
nav {
float: right;
margin-top: 35px;
}
li {
font-size: 18px;
display: inline-block;
margin-left: 48px;
}
a {
color: white;
text-decoration: none;
}
.banner > img {
width: 100%;
}
.wrap .block-row {
background: white;
}
.wrap #block1{
margin-left:80px;
margin-right:80px;
margin-top:80px;
width:100px;
height:100px;
background-color:#2fcbe0;
border-radius:100px;
display:inline-block;
}
.wrap #block2{
margin-left:80px;
margin-right:80px;
margin-top:80px;
width:100px;
height:100px;
background-color:#2fcbe0;
border-radius:100px;
display:inline-block;
}
.wrap #block3{
margin-top:80px;
margin-left:80px;
margin-right:80px;
width:100px;
height:100px;
background-color:#2fcbe0;
border-radius:100px;
display:inline-block;
}
.wrap #block4{
margin-top:80px;
margin-left:80px;
margin-right:80px;
width:100px;
height:100px;
background-color:#2fcbe0;
border-radius:100px;
display:inline-block;
}
h1{margin-top:80px; font-size:48px;}
.block-row .wrap #block1 span{display:block;}
<body>
<header>
<div class="wrap">
<img src="logo.png" alt="logo">
<nav>
<ul>
<li><a href="">CONTACT US</a></li>
<li><a href="">SOFTWARE USED</a></li>
<li><a href="">PROJECT</a></li>
<li><a href="">ABOUT US</a></li>
<li><a href="">HOME</a></li>
</ul>
</nav>
</div>
</header>
<section class="banner">
<img src="building.png" alt="banner">
</section>
<h1>SOME ICONS</h1>
<section class="block-row">
<div class="wrap">
<div id="block1"><span> ABOUT </span></div>
<div id="block2"> </div>
<div id="block3"> </div>
<div id="block4"> </div>
</div>
</section>
</body>
答案 0 :(得分:3)
如果您想使用其他方式并像下面这样更新<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="20dp"
android:text="Name"
android:textColor="@color/Black"
android:textSize="16dp" />
<RelativeLayout
android:id="@+id/layout2"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_alignParentStart="true"
android:layout_below="@+id/textView1"
android:orientation="vertical">
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:text="Value"
android:textColor="@color/MainGreen"
android:textSize="18dp" />
</RelativeLayout>
<RelativeLayout
android:background="@drawable/edittext_box"
android:id="@+id/layout3"
android:layout_width="100dp"
android:layout_height="59dp"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_marginEnd="20dp"
android:orientation="vertical">
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="0dp"
android:layout_marginTop="0dp"
android:inputType="number"
android:singleLine="true"
android:textAlignment="center"
android:textColor="@color/Black"
android:textSize="18dp" />
</RelativeLayout>
</RelativeLayout>
,则可以使用:after
codepen链接https://codepen.io/nasser-ali-karimi/pen/MZWeWL
.block-row .wrap #block1 span{display:block;}
然后您的html只需更新此部分
.block-row .wrap #block1:after{
content:'hello world';
display: block;
position: relative;
text-align: center;
width: 100px;
top: 100%;
}
.block-row .wrap #block2:after{
content:'hello world2';
display: block;
position: relative;
text-align: center;
width: 100px;
top: 100%;
}
.block-row .wrap #block3:after{
content:'hello world3';
display: block;
position: relative;
text-align: center;
width: 100px;
top: 100%;
}
.block-row .wrap #block4:after{
content:'hello world4';
display: block;
position: relative;
text-align: center;
width: 100px;
top: 100%;
}
答案 1 :(得分:0)
您可以将pseudo
用作:afetr
的{{1}},并在#block
中设置文本。
另请参见标记您的代码
content
.wrap .block-row {
background: white;
}
.wrap .circle{
margin-left:80px;
margin-right:80px;
margin-top:80px;
width:100px;
height:100px;
background-color:#2fcbe0;
border-radius:100px;
display:inline-block;
text-align:center;
position: relative;
}
.wrap .circle:after{
content: 'ABOUT';
position: absolute;
bottom: -18px;
left: 24px;
}
.wrap #block2:after{
content: 'SOME OTHER';
bottom: -34px;
}
答案 2 :(得分:0)
您可以对文本范围使用绝对值,对#block1,... 2,3,4父级位置使用相对值,使用span的“底部”属性,可以在块和文本之间留出空格:
html,
body {
font-family: Bahnschrift;
font-size: 13;
}
h1,h2,h3{margin: auto; text-align:center;}
.wrap {
max-width: 1100px;
margin: 0 auto;
}
header {
width: 100%;
height: 108px;
background-color: #001e22;
}
header .wrap > img {
margin-top: 17px;
}
nav {
float: right;
margin-top: 35px;
}
li {
font-size: 18px;
display: inline-block;
margin-left: 48px;
}
a {
color: white;
text-decoration: none;
}
.banner > img {
width: 100%;
}
.wrap .block-row {
background: white;
}
.wrap #block1{
margin-left:80px;
margin-right:80px;
margin-top:80px;
width:100px;
height:100px;
background-color:#2fcbe0;
border-radius:100px;
display:inline-block;
}
.wrap #block2{
margin-left:80px;
margin-right:80px;
margin-top:80px;
width:100px;
height:100px;
background-color:#2fcbe0;
border-radius:100px;
display:inline-block;
}
.wrap #block3{
margin-top:80px;
margin-left:80px;
margin-right:80px;
width:100px;
height:100px;
background-color:#2fcbe0;
border-radius:100px;
display:inline-block;
}
.wrap #block4{
margin-top:80px;
margin-left:80px;
margin-right:80px;
width:100px;
height:100px;
background-color:#2fcbe0;
border-radius:100px;
display:inline-block;
}
.wrap #block1,
.wrap #block2,
.wrap #block3,
.wrap #block4 {
position: relative;
}
.wrap #block1 span,
.wrap #block2 span,
.wrap #block3 span,
.wrap #block4 span {
position: absolute;
bottom: -20px;
width: 100%;
text-align: center;
}
h1{margin-top:80px; font-size:48px;}
.block-row .wrap #block1 span{display:block;}
<body>
<header>
<div class="wrap">
<img src="logo.png" alt="logo">
<nav>
<ul>
<li><a href="">CONTACT US</a></li>
<li><a href="">SOFTWARE USED</a></li>
<li><a href="">PROJECT</a></li>
<li><a href="">ABOUT US</a></li>
<li><a href="">HOME</a></li>
</ul>
</nav>
</div>
</header>
<section class="banner">
<img src="building.png" alt="banner">
</section>
<h1>SOME ICONS</h1>
<section class="block-row">
<div class="wrap">
<div id="block1"><span> ABOUT </span></div>
<div id="block2"> <span> SOME TEXT </span></div>
<div id="block3"> <span> SOME TEXT </span></div>
<div id="block4"><span> SOME TEXT </span> </div>
</div>
</section>
</body>
答案 3 :(得分:0)
html,
body {
font-family: Bahnschrift;
font-size: 13;
}
h1,h2,h3{margin: auto; text-align:center;}
.wrap {
max-width: 1100px;
margin: 0 auto;
}
header {
width: 100%;
height: 108px;
background-color: #001e22;
}
header .wrap > img {
margin-top: 17px;
}
nav {
float: right;
margin-top: 35px;
}
li {
font-size: 18px;
display: inline-block;
margin-left: 48px;
}
a {
color: white;
text-decoration: none;
}
.wrap #block1 {
margin-top: 80px;
width: 100px;
height: 100px;
background-color: #2fcbe0;
border-radius: 100px;
display: inline-block;
}
.wrap #block2 {
margin-top: 80px;
width: 100px;
height: 100px;
background-color: #2fcbe0;
border-radius: 100px;
display: inline-block;
}
.wrap #block3 {
margin-top: 80px;
width: 100px;
height: 100px;
background-color: #2fcbe0;
border-radius: 100px;
display: inline-block;
}
.wrap #block4 {
margin-top: 80px;
width: 100px;
height: 100px;
background-color: #2fcbe0;
border-radius: 100px;
display: inline-block;
}
.main-block {
width: 100px;
float: left;
text-align: center;
margin:0px 80px;
}
<header>
<div class="wrap">
<img src="logo.png" alt="logo">
<nav>
<ul>
<li><a href="">CONTACT US</a></li>
<li><a href="">SOFTWARE USED</a></li>
<li><a href="">PROJECT</a></li>
<li><a href="">ABOUT US</a></li>
<li><a href="">HOME</a></li>
</ul>
</nav>
</div>
</header>
<section class="banner">
<img src="building.png" alt="banner">
</section>
<h1>SOME ICONS</h1>
<section class="block-row">
<div class="wrap">
<div class="main-block">
<div id="block1"></div>
<span> ABOUT </span>
</div>
<div class="main-block">
<div id="block2"></div>
<span> ABOUT </span>
</div>
<div class="main-block">
<div id="block3"></div>
<span> ABOUT </span>
</div>
<div class="main-block">
<div id="block4"></div>
<span> ABOUT </span>
</div>
</div>
</section>