青亭浅 2023-12-18 23:41 采纳率: 88.2%
浏览 6
已结题

关于#css#的问题

怎末让着串字显示上去,且在屏幕中间

img

img


* {
    padding: 0;
    margin: 0;
    transition: all 0.5s;
}

body {
    overflow: hidden;
     transform: all 0.5s;
}
.text{
    float: right;
}
.navbar {
    position: relative;
    width: 100vw;
    float: left;
}

#checkbox {
    display: none;
}

.navbar label {
    position: absolute;
    top: 0;
    left: 70px;
    width: 100%;
    height: 43px;
    font-size: 30px;
    color: #5a738e;
    background-color: #ededed;
    padding-left: 20px;
    border: 1px solid #d9dee4;
    cursor: pointer;
    transition: all 0.5s;
}

.navbar ul {
    list-style: none;
    width: 70px;
    height: 100vh;
    background-color: #2a3f54;
    
    overflow: hidden;
}

.navbar ul li {
    height: 70px;
    margin-bottom: 10px;
}

.navbar ul li:first-child {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 10px;
}

.navbar ul li:first-child img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
}

.navbar ul li:first-child span {
    color: #fff;
    white-space: nowrap;
    padding-left: 10px;
    display: none;
}

.navbar ul li a {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    width: 100%;
    height: 100%;
    color: #d1d1d1;
    text-decoration: none;
}

.navbar ul li a i {
    font-size: 25px;
    margin-bottom: 10px;
}

.navbar ul li a span {
    font-size: 12px;
    white-space: nowrap;
}

.navbar ul li a:hover {
    color: #fff;
    background-color: #35495d;
}

.navbar input:checked + label{
    left: 200px;
}

.navbar input:checked ~ ul{
    width: 200px;
}

.navbar input:checked ~ ul li:first-child{
    justify-content: flex-start;transition: all 0.5s;
}

.navbar input:checked ~ ul li:first-child span{
    display: block;
}

.navbar input:checked ~ ul li a{
    flex-direction: row;
    justify-content: flex-start;
}

.navbar input:checked ~ ul li a i{
    font-size: 18px;
    margin: 0 15px 0 30px;
}

.navbar input:checked ~ ul li a span{
    font-size: 14px;
}


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>侧边展开导航栏</title>
    <link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <link rel="stylesheet" href="css/index.css">
</head>
<style>
</style>
<body>
<div class="navbar" >
    <input type="checkbox" id="checkbox">
    <label for="checkbox">
        <img src="image/bars.png" width="20" height="20">
    </label>
    <ul>
        <li>
            <img src="image/lufei.png" alt="">
            <span>欢迎您!同学</span>
        </li>
        <li>
            <a href="index.html">
                <img src="image/首页.png" width="20" height="20">

                <span>班级首页</span>
            </a>
        </li>
        <li>
            <a href="study.html">
                <img src="image/学习园地.png" width="20" height="20">

                <span>学习园地</span>
            </a>
        </li>
        <li>
            <a href="contacts.html">
                <img src="image/通讯录%20(1).png" width="20" height="20">

                <span>通讯录</span>
            </a>
        </li>
        <li>
            <a href="employment.html">
                <img src="image/待付款.png" width="20" height="20">

                <span>求职就业</span>
            </a>
        </li>
        <li>
            <a href="photo.html">
                <img src="image/照片.png" width="20" height="20">

                <span>班级相册</span>
            </a>
        </li>
    </ul>

</div>

<div class="text">
    深度学习西方成功v环保节能喀麦隆,大幅提高v还有八九年喀麦隆,;。‘
</div>


</body>
</html>


  • 写回答

2条回答 默认 最新

  • 浪客 2023-12-19 01:11
    关注
    
    .navbar {
        position: relative;
        /* width: 100vw; */
        float: left;
    }
    .navbar label {
        position: absolute;
        top: 0;
        left: 70px;
        /* width: 100%; */
        height: 43px;
        font-size: 30px;
        color: #5a738e;
        background-color: #ededed;
        padding-left: 20px;
        border: 1px solid #d9dee4;
        cursor: pointer;
        transition: all 0.5s;
        width: 100vw;
    }
    .text {
        margin-top: 45px;
        text-align: center;
        width: 100%;
        position: fixed;
    }
    

    文字居中也可以

    
    .text {
        text-align: center;
        width: 100%;
        position: absolute;
        top: 50%;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 12月27日
  • 已采纳回答 12月19日
  • 修改了问题 12月18日
  • 修改了问题 12月18日
  • 展开全部

悬赏问题

  • ¥15 Stable Diffusion视频动画制作时,第一步蒙版生成报错怎么处理啊,蒙版和帧图没法生成
  • ¥15 请把下列每一行代码完整地读懂并注释出来
  • ¥15 pycharm运行main文件,显示没有conda环境
  • ¥15 易优eyoucms关于二级栏目调用的问题
  • ¥15 寻找公式识别开发,自动识别整页文档、图像公式的软件
  • ¥15 为什么eclipse不能再下载了?
  • ¥15 编辑cmake lists 明明写了project项目名,但是还是报错怎么回事
  • ¥15 关于#计算机视觉#的问题:求一份高质量桥梁多病害数据集
  • ¥15 特定网页无法访问,已排除网页问题
  • ¥50 如何将脑的图像投影到颅骨上