display:block 的认识

本文介绍了使用CSS样式实现页面布局和交互效果的方法,通过设置HTML元素的样式属性,如display、white-space等,以及利用JavaScript实现动态效果,增强用户体验。

white-space:nowrap; + display:block  下面一种情况要注意

<style type="text/css">
    html {
        overflow: hidden;
    }
    body {
        background: #222;
    }
    #menu {
        padding: 10px;
        background: #000;
        height: 300px;
        width: 400px;
    }
    #menu a {
        display:block;
        text-decoration:none;
        font-family: arial, helvetica, verdana, sans-serif;
        white-space: nowrap;
    }

</style>

<script type="text/javascript"><!--
var P,T;
var over = -1;

///////////////
var fontSize = 38;
var lensFX = 1;
var num = true;
var color = "#FFF";
var selected = "#F80";
///////////////

function zoom(s){
    if(s!=over){
        over = s;
        for(var i=0;i<T;i++){
            P[i].style.fontSize=Math.floor(fontSize / (Math.abs(i - s) +

lensFX) + 3)+"px";
            P[i].style.color=(i==s)?selected:color;
        }
    }
}

onload = function(){
    P = document.getElementById("menu").getElementsByTagName("a");
    T = P.length;
    for (var i=0;i<T;i++){
        if(num){
            x=i+".";
            if(x.length<3)x="0"+x;
            P[i].innerHTML = x+P[i].innerHTML;
        }
        P[i].style.width = "100%";
        P[i].onmouseover=new Function("zoom("+i+");");
    }
    zoom(0);
}
//-->
</script>
</head>

<body>

    <div id="menu">
        <a href="#">scripting</a>
        <a href="#">javascript</a>
        <a href="#">web</a>
        <a href="#">dhtml</a>
        <a href="#">css</a>
        <a href="#">ajax</a>
        <a href="#">programming</a>
        <a href="#">design</a>
        <a href="#">webdesign</a>
        <a href="#">html</a>
        <a href="#">dom</a>
        <a href="#">webdev</a>
        <a href="#">reference</a>
        <a href="#">tools</a>
        <a href="#">tutorial</a>
        <a href="#">xmlhttprequest</a>
        <a href="#">menu</a>
        <a href="#">xml</a>
        <a href="#">library</a>
        <a href="#">development</a>

    </div>

</body>

转载于:https://www.cnblogs.com/luhangnote/archive/2012/09/13/2683766.html

<script setup> import {onMounted,ref} from 'vue' const handleTabChange = ()=>{ uni.navigateTo({ url: '/pages/circle/circle' }) } const windowHeight = ref(0) const scale = ref(0) onMounted(()=>{ const windowInfo = uni.getSystemInfo() uni.getSystemInfo({ success: (res) => { // 提取可视区域高度(px),与 getWindowInfo() 的 windowHeight 一致 windowHeight.value = res.windowHeight*2; console.log('可视区域高度(px):', res.windowHeight); scale.value = windowHeight.value/800 console.log("压缩比例",scale.value); }, fail: (err) => { console.error('获取系统信息失败:', err); } }) }) </script> <template> <view class="container"> <!-- 消息通知 --> <view class="message"> <img src="../../static/images/铃铛.png" alt="" style="width: 65rpx;height: 65rpx;"> </view> <!-- 个人信息区 --> <view class="information"> <img src="@/static/images/未登录头像.png" alt="" style="width: 120rpx;height: 120rpx;"> <view class="personal-information"> <view class="name"> <text id="nickname">未登录</text> <text id="compileInformation">编辑资料</text> </view> <view class="id-location"> <text id="id">id:983602377</text> <text id="location">江苏</text> </view> </view> </view> <!-- 个人简介区 --> <view class="introduce"> <view id="show"> <text>个人简介</text> <img src="../../static/images/铅笔.png" alt="" style="width: 30rpx;height: 30rpx;"> </view> <view id="compileIntroduce"> <input type="text" placeholder="分享人生格言,让大家认识你..." > </view> </view> <!-- 兴趣标签 --> <view class="interest-tags"> <view class="title"> <text>兴趣标签</text> <img src="../../static/images/小箭头.png" alt="" style="width: 10rpx;height: 15rpx;"> </view> <view class="tags"> <view class="tags-item">民间故事</view> <view class="tags-item">京剧鉴赏</view> <view class="tags-item">京剧鉴赏</view> <view class="tags-item">京剧鉴赏</view> <view class="tags-item">京剧鉴赏</view> <view class="tags-item">京剧鉴赏</view> <view class="tags-item">京剧鉴赏</view> <view class="tags-item">京剧鉴赏</view> <view class="tags-item">京剧鉴赏</view> <view class="tags-item">京剧鉴赏</view> </view> </view> <!-- 发布的帖子和参加的活动 --> <view class="participation"> <view class="title"> <view> <text>帖子</text> <view style="width: 64rpx;height: 8rpx;border-radius: 20rpx;background: rgba(254, 212, 198, 1);"></view> </view> <view> <text>活动</text> <view style="width: 64rpx;height: 8rpx;border-radius: 20rpx;background: rgba(254, 212, 198, 1);"></view> </view> </view> <view class="content"> <view class="content-list"> <view class="content-item"> <view class="cover"> <img src="../../static/images/活动图片1.png" alt="" style="width: 280rpx; height: 356rpx;"> </view> <view class="message"> <view class="host"> <img src="../../static/images/活动头像1.png" alt="" style="width: 30rpx; height: 30rpx;"> <text class="nickname">风起</text> </view> <view class="count"> <img src="../../static/images/参加人数.png" alt="" style="width:17rpx;height:17rpx;"> <text class="particapant">321</text> </view> </view> </view> </view> </view> </view> <!-- 自定义导航栏 --> <view class="tabbar" :style="{backgroundSize:`${800*scale}rpx ${800*scale}rpx`,backgroundPosition:`-346rpx ${-(windowHeight-145)}rpx`}"> <view class="circle" @click="handleTabChange"> <img src="@/static/tabs/星球未选中.png" alt="" style="width: 50rpx; height: 50rpx; margin-bottom:10rpx;"> <text style="color: rgba(204, 204, 204, 1)">星趣圈</text> </view> <view class="my"> <img src="@/static/tabs/我的选中.png" alt="" style="width: 50rpx; height: 50rpx; margin-bottom:10rpx;"> <text style="color: rgba(255, 204, 184, 1);">我的</text> </view> </view> </view> </template> <style lang="scss"> page{ position:fixed; top:0rpx; left:0rpx; height:100%; width:100%; background-image:url('https://img.js.design/assets/img/68a6c2073f22157da6132401.png'); background-size: cover; background-repeat: no-repeat; background-position: -346rpx 0rpx; } .container{ overflow-y: scroll; overflow-x: scroll; height: 100%; position: relative; // 消息通知 .message{ position:absolute; left:640rpx; top:80rpx; } // 个人信息 .information{ position:absolute; top:147rpx; left:36rpx; width: 457rpx; height:120rpx; display:flex; gap: 34rpx; .personal-information{ display:flex; flex-direction: column; gap:26rpx; .name{ display:flex; align-items: center; gap:19rpx; #nickname{ font-size: 36rpx; font-weight: 700; } #compileInformation{ width: 120rpx; height: 36rpx; background-color: rgba(254, 212, 198, 0.62); border:1rpx solid rgba(128, 128, 128, 1); border-radius: 20rpx; font-size: 20rpx; font-weight: 500; line-height: 36rpx; color: rgba(128, 128, 128, 1); text-align: center; } } .id-location{ display:flex; gap:29rpx; align-items: center; #id{ font-size: 24rpx; font-weight: 500; color: rgba(166, 166, 166, 1); } #location{ width: 96rpx; height: 35rpx; border-radius: 30rpx; background: rgba(254, 212, 198, 0.62); border:1rpx solid rgba(128, 128, 128, 1); border-radius: 20rpx; font-size: 24rpx; font-weight: 500; text-align: center; line-height: 35rpx; color: rgba(128, 128, 128, 1); } } } } // 个人简介 .introduce{ position:absolute; top:300rpx; left:60rpx; display:flex; flex-direction: column; gap:28rpx; #show{ margin-left:4rpx; display:flex; gap:5rpx; width: 131rpx; height: 30rpx; text{ font-size: 24rpx; font-weight: 500; color: rgba(0, 0, 0, 1); } } #compileIntroduce{ input{ font-size: 24rpx; font-weight: 400; background-color: rgba(255, 250, 247, 1); border-radius: 10rpx; padding:10rpx; width: 610rpx;height: 45rpx; } } } // 兴趣标签 .interest-tags{ position:absolute; left:64rpx; top:480rpx; .title{ display:inline-block; height:25rpx; margin-bottom:28rpx; text{ font-size: 24rpx; font-weight: 500; margin-right:17rpx; } img{ vertical-align: bottom; } } .tags{ width:630rpx; display:grid; grid-template-columns: repeat(5,1fr); gap:12rpx; .tags-item{ background-color: rgba(255, 201, 201, 1); width: 101rpx; height: 25rpx; text-align: center; border-radius: 10rpx; font-size: 18rpx; font-weight: 500; line-height:25rpx; color:white; } } } // 参与 .participation{ position:absolute; top:648rpx; width: 100%; box-sizing: border-box; .title{ height:85rpx; width: 670rpx; border-radius: 20rpx; background-color: rgba(255, 255, 255, 1); margin:0 auto; margin-bottom:21rpx; font-size: 28rpx; font-weight: 500; display:flex; gap:91rpx; align-items: center; text-align: center; &>view:first-child{ margin-left:91rpx; } } .content{ width: 670rpx; margin: 0 auto; padding:19rpx 26rpx; border-radius: 20rpx; background-color: rgba(255, 247, 247, 0.7); box-sizing: border-box; margin-bottom:145rpx; .content-list{ display:grid; grid-template-columns: repeat(2,1fr); gap:16rpx; .content-item{ display: flex; flex-direction: column; gap:20rpx; align-items: center; width: 300rpx; height:429rpx; border-radius: 10rpx; background-color: rgba(255, 255, 255, 1); padding:8rpx 10rpx 15rpx 10rpx; box-sizing: border-box; border:1rpx solid red; .cover{ width:280rpx; border:1rpx solid red; } .message{ width: 280rpx; height:30rpx; display:flex; justify-content: space-between; align-items: center; border:1rpx solid red; .host{ display:flex; gap:12rpx; .nickname{ font-size: 14rpx; font-weight: 500; line-height:30rpx; } } .count{ display:flex; gap:7rpx; height:30rpx; align-items: center; margin-right:20rpx; .particapant{ font-size: 11rpx; font-weight: 500; color: rgba(128, 128, 128, 1); } } } } } } } // 导航栏 .tabbar{ position:fixed; bottom:0rpx; width: 100%; height:145rpx; display:flex; justify-content: space-evenly; font-size: 20rpx; font-weight: 400; background:url('https://img.js.design/assets/img/68a6c2073f22157da6132401.png'); .circle{ padding-top:21rpx; display:flex; flex-direction: column; align-items: center; } .my{ padding-top:21rpx; display:flex; flex-direction: column; align-items: center; } } } </style>
08-30
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值