鱼C论坛

 找回密码
 立即注册
查看: 2616|回复: 9

[已解决]网页布局问题

[复制链接]
发表于 2021-12-16 23:51:57 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 gameking2oo8 于 2021-12-16 23:56 编辑

网页布局问题

网页布局问题


请问如何让这些按钮看上去更舒服,怎么布局?

最终是用手机游览器预览上面的内容。

test1.zip (1.66 KB, 下载次数: 0)
最佳答案
2022-1-4 10:04:39
用css,我给你一篇代码,或与你能用到,我也是萌新,看不懂,只能你自己琢磨了。
<!DOCTYPE html>
<html>
<head>

   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>COCC Home</title>

    <style>
        body {
            margin: 0;
            padding: 0;
        }

        
        div {
            position: absolute;
            margin: 0 auto;
            left: 653px;
            top: 70px;
        }
        
        input {
            position: absolute;
            outline: none;
            font-size: 20px;
            border: 2px solid #4e6ef2;
            border-radius:10px;
            width: 185%;
            height: 40px;
            left: -75%;
            top: 100%;
        }
        
        button {
            position: absolute;
            outline: none;
            font-size: 15px;   
            border-radius:10px;
            color: white;
            background: #4e6ef2;
            width: 25%;
            height: 44px;
            left: 113%;
            top: 100%;
        }
        
        button:hover {
            background: #2D5EE3;
        }
    </style>
    <script>
        window.onload = function (){
            var oBtn = document.getElementsByTagName("button")[0];
            var oTxt = document.getElementsByTagName("input")[0];
            
            function click() {
                if (oTxt.value == "") {
                    location.reload();
                } else {
                    window.open("https://www.baidu.com/s?wd=" + oTxt.value);
                }
            }
            
            oBtn.onclick = click;
            oTxt.onkeydown = function(e) {
                if (!e) e = window.event;
                if (e.keyCode == 13) {
                    click();
                }
            }
        }
    </script>
</head>
  <body>
<div>

        <h1 style="font-size:350%">
                COCC Home</h1>
        <input type="text">
        <button>Go</button>
  </div>
<style tpye="text/css">
.代码{
        position: absolute;
        width:268px;
        height:300px;
        }
.代码 p{
        position: absolute;
        bottom: 0;
        width:140%;
        text-align:center;   
     }
</style>
        <div class="代码">
                <p>&copy;COCC Home-2021(Mingwei Wei)</p>
</div>
  </body>
</html>
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2021-12-17 15:34:10 | 显示全部楼层
改颜色?换图形样式?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-12-31 10:47:32 | 显示全部楼层
宽高度自适应一下?然后使用Position定位
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-1-1 19:05:54 | 显示全部楼层
你把css学完就知道了
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-1-4 10:04:39 | 显示全部楼层    本楼为最佳答案   
用css,我给你一篇代码,或与你能用到,我也是萌新,看不懂,只能你自己琢磨了。
<!DOCTYPE html>
<html>
<head>

   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>COCC Home</title>

    <style>
        body {
            margin: 0;
            padding: 0;
        }

        
        div {
            position: absolute;
            margin: 0 auto;
            left: 653px;
            top: 70px;
        }
        
        input {
            position: absolute;
            outline: none;
            font-size: 20px;
            border: 2px solid #4e6ef2;
            border-radius:10px;
            width: 185%;
            height: 40px;
            left: -75%;
            top: 100%;
        }
        
        button {
            position: absolute;
            outline: none;
            font-size: 15px;   
            border-radius:10px;
            color: white;
            background: #4e6ef2;
            width: 25%;
            height: 44px;
            left: 113%;
            top: 100%;
        }
        
        button:hover {
            background: #2D5EE3;
        }
    </style>
    <script>
        window.onload = function (){
            var oBtn = document.getElementsByTagName("button")[0];
            var oTxt = document.getElementsByTagName("input")[0];
            
            function click() {
                if (oTxt.value == "") {
                    location.reload();
                } else {
                    window.open("https://www.baidu.com/s?wd=" + oTxt.value);
                }
            }
            
            oBtn.onclick = click;
            oTxt.onkeydown = function(e) {
                if (!e) e = window.event;
                if (e.keyCode == 13) {
                    click();
                }
            }
        }
    </script>
</head>
  <body>
<div>

        <h1 style="font-size:350%">
                COCC Home</h1>
        <input type="text">
        <button>Go</button>
  </div>
<style tpye="text/css">
.代码{
        position: absolute;
        width:268px;
        height:300px;
        }
.代码 p{
        position: absolute;
        bottom: 0;
        width:140%;
        text-align:center;   
     }
</style>
        <div class="代码">
                <p>&copy;COCC Home-2021(Mingwei Wei)</p>
</div>
  </body>
</html>
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-1-25 17:51:52 | 显示全部楼层
弹性盒子整试试?要改动样式格式用css改呗
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-3-24 15:26:07 From FishC Mobile | 显示全部楼层
emmm,颜色,边框,大小,
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-5-25 21:08:42 | 显示全部楼层
# 建议看书学习CSS 让按钮变得好看
一般都是增加颜色,box-shadow, border-radius使得按钮有立体感
然后增加点击后 改变CSS效果,让按钮看起来被点击了
现在流行扁平化设计
总结: 看书学CSS,基础打牢
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-5-26 11:53:49 | 显示全部楼层
flex
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2022-6-2 16:22:25 | 显示全部楼层
你想怎么舒服
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-20 04:07

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表