简体   繁体   English

放大或缩小时对齐列表项

[英]aligning list items when zoomed in or zoomed out

i'm willing to write a code to have my list items(li)aligned in center and have their distance change when i zoom in or out(so they will always stay in the middle of the page) but when i zoom in or zoom out, they keep their distances and flow out of the page here is my code for lis: 我愿意编写代码以使列表项(li)居中对齐,并在我放大或缩小时更改其距离(因此它们始终位于页面中间),但是当我放大或缩放时离开,他们保持距离并离开页面,这是我的lis代码:

#inlinelist
{
    display:inline;
    padding:1px;
    border:solid 1px;
    margin-left:15%;
}
</style>

and here is my ul with lis: 这是我与lis的ul:

<div>
<ul style="list-style-type:none;
position:inherit;
width:100%;">
<li id="inlinelist">ggl</li>
<li id="inlinelist">ggl</li>
<li id="inlinelist">ggl</li>
<li id="inlinelist">ggl</li>
</ul>
</div>

i don't know if i need js or something(if you know the code in js,please tell me) tnx 我不知道我是否需要js或其他东西(如果您知道js中的代码,请告诉我)tnx

Not using media queries : 不使用media queries

Is THIS DEMO is what are you trying to do? 这个演示是您要做什么吗?

There is something they call responsive design it might help you out ;) 他们称之为响应式设计的东西可能会帮助您;)

it changes because of the fact that screen width isn't the same on every screen + if you scale down the browser window it also changes. 它的变化是因为每个屏幕的屏幕宽度都不相同,如果您缩小浏览器窗口,它也会发生变化。

the solution is doing this: 解决方案是这样做的:

you can fix this by using @media query's and a viewport in your css , and add this meta tag to your html: 您可以通过使用@media查询和CSS中的视口来解决此问题,并将此meta标签添加到html中:

 <meta name="viewport" content="width=device-width,initial-scale = 1.0,maximum-scale = 1.0”>

and with the @media query's and viewport you declare what size you have per screen width using this media query + viewport in css: 并使用@media查询和视口,使用CSS中的此媒体查询+视口来声明每个屏幕宽度的大小:

 @media screen and (min-width: 820px) and (max-width: 920px) {
  @viewport { width: 820px; }   

// your css for screens between 820 and 920 pixels in width goes here //宽度介于820和920像素之间的屏幕的CSS

  }

i mostly use the value's : from 20 - 600 , 600-700 , 700-820 , 820 - 920 , 920 - 1200, @media screen and (min-width: 1200px){ @viewport { width: 1200px; 我主要使用以下值:20-600,600-700,700-820,820-920,920-1200,@media屏幕和(min-width:1200px){@viewport {width:1200px; }(this last one will set the size for any screen bigger than 1200 px in width so your code for the biggest version goeds here} }(最后一个将为任何宽度大于1200 px的屏幕设置尺寸,因此此处使用的是最大版本的代码)

So this means you will have 6 times your css code which is adapted will be adapted to the size. 因此,这意味着您将获得6倍的CSS代码,该代码将根据大小进行调整。

This is called adaptive or responsive design and is pretty easy to do 这称为自适应或响应式设计,非常容易做到

For more info you might check this http://css-tricks.com/snippets/css/media-queries-for-standard-devices/ 有关更多信息,您可以查看此http://css-tricks.com/snippets/css/media-queries-for-standard-devices/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM