神奇的网页适应手机的一句话

<meta name="viewport" content="width=device-width, initial-scale=1"/>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
好的,以下是一个简单的适应手机和电脑的HTML页面示例: ```html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>适应手机和电脑的页面</title> <style> .container { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; background-color: #f5f5f5; } .title { font-size: 2rem; margin-bottom: 1rem; } .content { font-size: 1.5rem; text-align: center; padding: 1rem; background-color: white; box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1); border-radius: 0.5rem; width: 90%; max-width: 30rem; } @media screen and (min-width: 768px) { .container { flex-direction: row; } .title { font-size: 4rem; margin-right: 2rem; } .content { font-size: 2rem; padding: 2rem; width: 50%; max-width: 40rem; } } </style> </head> <body> <div class="container"> <div class="title">适应手机和电脑的页面</div> <div class="content"> <p>这是一个适应手机和电脑的页面示例。</p> <p>使用CSS Flexbox和媒体查询可以实现页面在不同屏幕尺寸下的适配。</p> <p>在手机上,标题和内容垂直居中,宽度为90%;在电脑上,标题和内容水平排列,宽度为50%。</p> </div> </div> </body> </html> ``` 这个页面使用了CSS Flexbox布局和媒体查询,可以在不同屏幕尺寸下实现适配。在手机上,标题和内容垂直居中,宽度为90%;在电脑上,标题和内容水平排列,宽度为50%。同时,使用Viewport meta标签确保页面在不同设备上正确地显示。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

飞飞翼

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值