以下是一个兼容IE11的HTML代码,可以在浏览器中显示一个上下、左右居中的圆,点击后可以打开www.baidu.com:

<!DOCTYPE html>
<html>
<head>
<style>
    html, body {
        height: 100%;
        margin: 0;
        padding: 0;
    }
    .container {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100%;
    }
    .circle {
        width: 20px;
        height: 20px;
        background-color: green;
        border-radius: 50%;
        display: flex;
        justify-content: center;
        align-items: center;
        cursor: pointer;
    }
    .circle:hover {
        background-color: darkgreen;
    }
</style>
</head>
<body>
    <div class="container">
        <div class="circle" onclick="openBaidu()">
            启动IE
        </div>
    </div>

<script>
    function openBaidu() {
        window.open("http://www.baidu.com", "_blank");
    }
</script>
</body>
</html>

这段代码使用了Flexbox布局来实现上下、左右居中。在CSS中,.container类设置了display: flex;来创建一个Flexbox容器,并使用justify-content: center;align-items: center;将其中的元素上下、左右居中。.circle类设置了圆的样式,并使用display: flex;justify-content: center;align-items: center;将其中的文本内容居中显示。onclick属性绑定了一个JavaScript函数,当点击圆时会调用openBaidu()函数,该函数使用window.open方法打开一个新的窗口,显示www.baidu.com

写一个html显示上下、左右居中的圆20px20px绿色圆上居中显示启动IE点击后打开wwwbaiducom兼容IE11

原文地址: https://www.cveoy.top/t/topic/iMSC 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录