@雾 2022-05-24 06:17 采纳率: 66.7%
浏览 35
已结题

音乐播放器效果出不来

问题遇到的现象和发生背景
问题相关代码,请勿粘贴截图

[](

<link rel="stylesheet" href="css/audio.css" media="screen" type="text/css"/>
        <link rel="stylesheet" href="css/font-awesome.css" media="screen" type="text/css"/>
    </head>
    <body>
        <!--container 控制整体页面布局 -->
        <div id="container">
            
            <div id="player">
                <!--引入音频源文件-->
                <audio id="audio" >
                    <source src="audio/music.mp3" type="audio/mpeg" codecs="mp3"></source>
                </audio>
                <!--引入专辑封面图片-->
                <img src="images/music.jpg" />
                <!--制作显示歌词的按钮-->
                <label class="to-lyrics-label" for="to-lyrics">
                    <i class="fa fa-caret-down fa-1g"></i>
                </label>
                <input type="checkbox" id="to-lyrics" />
                
                <!--歌词切换-->
                <!-- cover 用于定义按钮,歌曲信息和歌词 -->
                <div class="cover">
                    <!-- 定义控制按钮 -->
                    <div class="controls">
                        <button title="循环播放"><i class="fa fa-retweet fa-1g"></i></button>
                        <button title="上一曲"><i class="fa fa-backward fa-2x"></i></button>
                        <button title="播放" id="play-pause" onclick="togglePlayPause()"><i class="fa fa-play fa-3x"></i></button>
                        <button title="下一曲"><i class="fa fa-forward fa-2x"></i></button>
                        <button title="顺序播放"><i class="fa fa-random fa-1g"></i></button>
                        <input name="音量" id="volume" min="0" max="1" step="0.1" type="range" onchange="setVolume()"/>
                    </div>
                    <!-- 定义歌曲信息 -->
                    <div class="info">
                        <p class="song"><a href="#" target="_blank">陪你度过漫长岁月</a></p>
                        <p class="author"><a href="#" target="_blank">陈奕迅</a></p>
                    </div>
                    <!-- 定义歌词 -->
                    <div class="lyrics">
                        <P>陪你度过漫长岁月</P>
                        <P>演唱:陈奕迅</P>
                        
                        <P>走过了人来人往 不喜欢也得欣赏</P>
                        <P>我是沉默的存在 不当你的世界 只作你肩膀</P>
                        <P>拒绝成长到成长 变成想要的模样</P>
                        <P>在举手投降以前 让我再陪你一段</P>
                        
                        <P>陪你把沿路感想 活出了答案</P>
                        <P>陪你把独自孤单 变成了勇敢</P>
                        <P>一次次失去又重来 我没离开</P>
                        <P>陪伴是 最长情的告白</P>
                        <P>陪你把想念的酸 拥抱成温暖</P>
                        <P>陪你把彷徨 写出情节来</P>
                        <P>未来多漫长 再漫长 还有期待    </P>
                        <P>陪伴你 一直到 故事给说完</P>
                        
                        <P>让我们静静分享 此刻难得的坦白</P>
                        <P>只是无声地交谈 感觉幸福 感觉不孤单</P>
                    </div>
                    <p class="scroll">收起</p>
                </div>  <!-- cover -->
                
            </div>  <!-- player -->
        </div>  <!-- container -->
        <script src="js/audio.js"></script>


```)

```css
/* 并排放置两个带边框的框时,可令边框和内边距包含在指定宽度和高度内,来解决盒子被挤下去的问题 */
*,*:before,*:after{
    box-sizing: border-box;
}
body{
    margin: 0;
    min-height: 100%;
    background-color: #EEEEEE;
    font-family: 'Roboto Condensed',sans-serif;
    font-weight: 300;
}
a{
    color: #FFFFFF;
    text-decoration: none;
}
a:hover{
    color: #26c5cb;
}
p{
    margin: 0;
}
#container,#player,.cover{
    position: absolute;
    margin: auto;
    top: 0;
    left: 0;
    right: 0;
    border: 0;
}
#container{
    width: 320px;
    height: 320px;
}
#player{
    width: 300px;
    height: 300px;
    background-color: #FFFFFF;
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 2px 2px 20px 0 rgba(0,0,0,0.3);
    z-index: 300;
}
img{
    width: 100%;
    height: 100%;
    background-color: #FFFFFF;
    opacity: 0.75;
    
}

.controls{
    position: relative;
    width: 100%;
    color: #FFFFFF;
    text-align: center;
}
button{
    
    margin: 5px;
    color: #FFFFFF;
    background: transparent; /*背景透明*/
    border: 0;
    outline: 0;
    cursor: pointer;
    text-align: center;
    text-shadow: 1px 1px 2px #000 ;
    transition: all 0.3s ease-in-out;
    -webkit-transition: all 0.3s ease-in-out;
}
button:hover{
    color: #26c5cb;
}
.info{
    position: relative;
    margin-top: 28px;
    bottom: 10px;
    color: #FFFFFF;
    text-align: center;
    text-shadow: 1px 1px 3px #000;
}
.song{
    font-size: 18px;
}
.author{
    font-size: 14px;
    margin-bottom: -0.5rem;
}
.song,.author{
    /* 以下三个属性写在一起表示该元素超出内容宽度显示为省略号 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
input[type='range']{
    display: block;
    margin: 14px auto;
    width: 80px;
    height: 2px;
    outline: 0;
    cursor: pointer;
    box-shadow: 1px 1px 3px 0 #FFFFFF;
}
input[type='range']::-webkit-slider-thumb{
    background-color: #aeaeae;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    transition:0.1s all linear ;
    -webkit-transition:0.1s all linear ;
    -webkit-appearance: none !important;
}
input[type='range']:hover::-webkit-slider-thumb{
    background-color: #26C5CB;
    -webkit-transform: scale(2);
}
input[type=checkbox]{
    position: absolute;
    top: -9999px;
    left: -9999px;
}
label{
    text-shadow: 1px 1px 3px #000;
}
.to-lyrics-label:hover{
    color: #26C5CB;
}
label.to-lyrics-label{
    position: absolute;
    top: 276px;
    left:50% ;
    width: 20px;
    height: 20px;
    margin-left: -5px;
    color: #FFFFFF;
    cursor: pointer;
    z-index: 500;
    
}
.lyrics{
    position: relative;
    width: 100%;
    height: 96px;
    margin-top: 30px;
    padding: 4px 24px;
    color: #000000;
    background: rgba(255,255,255,0.3);
    font-size: 12px;
    text-align: center;
    overflow-y: scroll;
    box-shadow: inset 0 -3px 5px 0 rgba(0,0,0,0.5);
    transition: all 0.5s ease-in-out;
    -webkit-transition: all 0.5s ease-in-out;
}
.lyrics:hover{
    background: rgba(255,255,255,0.8);
}
.lyrics::-webkit-scrollbar{
    display: none;
}
.scroll{
    color: #FFFFFF;
    text-align: center;
    font-size: 9px;
    font-weight: bold;
    text-shadow:1px 1px 3px #000000 ;
    
}
.cover{
    padding: 145px;
    transition: all 0.5s ease-in-out;
    -webkit-transition: all 0.5s ease-in-out ;
}
#to-lyrics:checked ~ .cover {
    padding-top:40px ;
    
}
#to-lyrics:checked ~ .cover .lyrics{
    margin-top: 0px;
}
#to-lyrics:checked ~ .cover button{
    margin-top: 0px;
}

运行结果及报错内容

按钮那些位置跟要的结果不一样

img

我的解答思路和尝试过的方法
我想要达到的结果

img

展开全部

  • 写回答

2条回答 默认 最新

  • 你好!机器人 2022-05-24 06:39
    关注

    controls加个display:flex

    .controls{
        position: relative;
        width: 100%;
        color: #FFFFFF;
        text-align: center;
        display:flex
    }
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

问题事件

  • 系统已结题 6月7日
  • 已采纳回答 5月30日
  • 创建了问题 5月24日
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部