英文:
Fixing the whitespace of a css box
问题
我尝试修复弹出框,当单击项目时会出现弹出框(这是用于演示餐厅网站的),其中内部内容设置为640像素。然而,该框周围有很多空白,我似乎无法弄清楚如何去除。
这里是创建弹出框的代码:
.popup {
height: 0%;
width: 100%;
position: fixed;
z-index: 100;
bottom: 0;
left: 0;
background-color: rgb(0,0,0);
background-color: rgba(0,0,0, 0.9);
/*overflow-x: hidden;*/
transition: 0.3s;
}
.popup-content {
position: relative;
top: 20%;
width: 100%;
padding-right: 36px;
margin-top: 2px;
text-align: center;
}
.popup a {
padding: 0px;
max-width: 700px;
text-decoration: none;
font-size: 36px;
color: #000000;
display: block;
}
我一直在尝试解决这个问题,但无法弄清楚实际框的大小是在哪里设定的。
英文:
I was trying to fix a popup box that appears when an item is clicked (this is for a demo restaurant site), which has inner content set to 640px. However, the box has a lot of whitespace around it that I cannot seem to figure out how to remove.
Here's the code to create the popup box:
.popup {
height: 0%;
width: 100%;
position: fixed;
z-index: 100;
bottom: 0;
left: 0;
background-color: rgb(0,0,0);
background-color: rgba(0,0,0, 0.9);
/*overflow-x: hidden;*/
transition: 0.3s;
}
.popup-content {
position: relative;
top: 20%;
width: 100%;
padding-right: 36px;
margin-top: 2px;
text-align: center;
}
.popup a {
padding: 0px;
max-width: 700px;
text-decoration: none;
font-size: 36px;
color: #000000;
display: block;
}
I've been poking around this for a bit but cannot figure out where the sizing of the actual box comes in.
答案1
得分: 0
代码部分不需要翻译,以下是翻译好的内容:
似乎问题可能出在.popup-content
类的top
属性上。它被设置为top: 20%;
,这意味着弹出内容将从其容器的顶部位置__20%__。这可能导致您遇到的空白。
尝试这种方法
- 将
.popup-content
类中的top
属性更改为top: 0;
:
.popup-content {
position: relative;
top: 0;
width: 100%;
padding-right: 36px;
margin-top: 2px;
text-align: center;
}
- 使用
padding
属性来设置弹出框内部的间距:
.popup-content {
/* 其他属性 */
padding: 20px; /* 或您需要的值 */
}
英文:
It seems that the issue might be with the top property of the .popup-content
class. It's set to top: 20%;
, which means that popup content will be positioned 20% from the top of its container. This might cause the whitespace you're experiencing.
Try this approach
- Change the top property in the .popup-content class to
top: 0;
:
.popup-content {
position: relative;
top: 0;
width: 100%;
padding-right: 36px;
margin-top: 2px;
text-align: center;
}
- use
padding
property for spacing inside the popup box:
.popup-content {
/* Other properties */
padding: 20px; /* or the value you need*/
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论