英文:
My css is not centering. Is there a way around this?
问题
.pop span
的文本未居中,而是保持在边缘。这是为什么?如果知道,请回复。
英文:
I am making a text editor, and I have a work counter. I want to center the word counter in my popup box, and it is not centering. Here is the code:
@import url("https://fonts.googleapis.com/css?family=Montserrat:400,400i,700");
body {
font-family: Montserrat, sans-serif;
}
h1{
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
text-align : center;
}
article {
text-align : justify;
overflow:auto;
line-height: 1.5;
height : 70vh;
margin : auto;
font-family: Montserrat, sans-serif;
outline : none;
width : 85%;
}
.outer {
display : flex;
}
.pops {
padding : 0px 15px;
}
.pop span {
text-align:center;
font-size : 20px;
color : #444;
text-align: center;
}
.pop{
transition: .5s;
width: 120px;
height : 70px;
border-radius: 5px;
border: 1px solid #BFBFBF;
background-color: white;
}
.pop:hover {
background-color : #eae8ff;
}
html:
<h1> StreamLine </h1>
<div class = "outer">
<article class = "child" id = "text" data-gramm="false"
data-gramm_editor="false"
data-enable-grammarly="false" contenteditable = "true" spellcheck = "true"> Write your amazing words here! </article>
<div class = "pops" > <div class = "pop"> <span class = "inner" id="words">0</span></div></div>
</div>
I wanted the text in the
.pop span
to center, but it didn't. Instead, it stayed at the edge. Does anyone know why this happened? If so, please reply.
答案1
得分: 1
将以下内容添加到您的CSS中的“.pop span”部分:
display: flex;
justify-content: center;
英文:
add the following to your CSS at ".pop span":
display: flex;
justify-content: center;
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论