HTML Responsive Web Page

本文介绍了一个简单的响应式网页设计实例,展示了如何使用HTML和CSS实现页面元素在不同设备上的自适应布局。示例中包含了伦敦、巴黎和东京三个城市的简介。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

注:参考网站 https://www.w3schools.com

HTML Responsive Web Page

index.html

<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" href="style.css">
        <title>Responsive web page</title>
        <meta lang="en" charset="utf-8">
    </head>
    <body>
        <h1>Responsive Web Design</h1>
        <div class="city">
            <h2>London</h2>
            <p>London is the capital city of England.</p>
            <p>It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants.</p>
        </div>

        <div class="city">
            <h2>Paris</h2>
            <p>Paris is the capital of France.</p>
            <p>The Paris area is one of the largest population centers in Europe, with more than 12 million inhabitants.</p>
        </div>

        <div class="city">
            <h2>Tokyo</h2>
            <p>Tokyo is the capital of Japan.</p>
            <p>It is the center of the Greater Tokyo Area,  and the most populous metropolitan area in the world.</p>
        </div>
    </body>
</html> 

style.css

h1 {
    text-align:center;
    background-color:black;
    padding:5px;
    color:white;
}
.city {
    height:200px;
    max-width:410px;
    border:1px solid grey;
    margin:10px;
    padding:5px;
    overflow:hidden;
    float:left;  /*关键是这一行代码,使得该代码能够在不同的设备上自适应的显示*/
}

显示结果为:
这里写图片描述
这里写图片描述
这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值