English 中文(简体)
• 如何在电网箱中进行横向和纵向的制图
原标题:how to horizontally and vertically center chart items in a grid box

我已经用了两小时的时间,但找不到解决办法。

我有两部<条码>。 我的<代码>ul集装箱中的单项物品

 <ul id="button-cash">
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
          
</ul>
#button-cash {
  display: grid;
  grid-template-columns: 60px 60px 60px 60px;
  grid-auto-rows: 10vh;
  align-items: center;
  justify-items: center;
  list-style-type: none;
  width: 100%;
  height: 300px;
  
}

li {
 width: 35px;
 height: 30px;
 background-color: rgb(65, 171, 185);
}

#price-screen, #button-cash, #cash-in-drawer {
   background-color: rgb(159, 227, 236);
}

我希望这一图表集中,以便试图在我的电网箱中添加这些特性。

  align-items: center;
  justify-items: center;

but instead i got this result sample

一览表略低于我集装箱的边缘

So I thought it would be smarter to make my grid container position: relative;

我在图表中增加了以下各点:

position: absolute;
top: 50%;
bottom: 50%;
transform(50%, -50%);

it worked but i got this result instead sample all the li fused into one single element while they were centralized

我认为,这一解决办法非常简单,但无法查明其是什么。

问题回答

我补充说了一个有理的争论点:使中心成为中心而不是正当的项目。 让我知道,这是否意味着什么?

#button-cash {
  display: grid;
  grid-template-columns: 60px 60px 60px 60px;
  align-items: center;
  justify-content: center;
  list-style-type: none;
  width: 100%;
  height: 300px;
  
  
}

li {
 width: 35px;
 height: 30px;
 background-color: rgb(65, 171, 185);
}

#price-screen, #button-cash, #cash-in-drawer {
   background-color: rgb(159, 227, 236);
}
<ul id="button-cash">
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
          
</ul>




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签