简体   繁体   English

如何在移动设备上解决简单 html/css 网站的缩放问题

[英]How to fix scaling issue on mobile for simple html/css website

I recently created a website in order to serve as a portfolio of sorts for any future projects that I complete during University.我最近创建了一个网站,以作为我在大学期间完成的任何未来项目的各种组合。 I self-taught myself Html/CSS to create the web-page so obviously the code itself is probably pretty poor quality.我自学了 Html/CSS 来创建网页,所以很明显代码本身的质量可能很差。 I'll probably be creating a new website when I learn React.js, but for now this is what I have.当我学习 React.js 时,我可能会创建一个新网站,但现在这就是我所拥有的。

The link is: https://etnwang.github.io/链接为: https://etnwang.github.io/

The files can be found at https://github.com/eTNwang/eTNwang.github.io这些文件可以在https://github.com/eTNwang/eTNwang.github.io中找到

I think the page looks decent on a desktop, but it completely breaks apart on mobile.我认为该页面在台式机上看起来不错,但在移动设备上却完全崩溃了。 I did my best to utilize percentages of width and height whenever possible and vh instead of px.我尽我所能尽可能利用宽度和高度的百分比,并使用 vh 而不是 px。 However, it still looks horrendous.然而,它看起来仍然很可怕。 I added the line我添加了行

    <meta name="viewport" content="width=device-width, initial-scale=1">

but it didn't do anything for the site.但它没有为网站做任何事情。

Anyone have any idea how to fix the mobile scaling issue?有人知道如何解决移动缩放问题吗?

On desktop:在桌面上:

looks decent看起来不错

On mobile:在移动:

terribleness可怕

You got a nice setup at start, where you position your elements in two different blocks with flex.一开始你有一个很好的设置,你在两个不同的块中使用 flex position 你的元素。 Nameblock as 60% width and your imgage with 40% width.名称块为 60% 宽度,您的图像为 40% 宽度。 However this gets really small on mobile.然而,这在移动设备上变得非常小。 I would reccomend in your case to add a different flex direction when the window gets smaller than 600px (for example).当 window 小于 600 像素(例如)时,我建议在您的情况下添加不同的弯曲方向。 And then also change your padding left as you want to position the image.然后根据需要更改您的填充左侧 position 图像。

@media (max-width:600px){ 
    .flex-container {
     flex-direction: column;
  }
.img img{ 
     padding-left: 15vh;
  } 
.nameblock{
     width:90%;
     margin: auto;
     padding-left:0;
  }
}

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

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