一、定位问题
按照视频写代码时,发现元素“5个“”定位不对,如下图

正常位置为

还以为是哪里写错了,仔细研究了下,需要在父div上加relative。

position:relative/absolute的父(祖先)节点的padding-box的区进行定位(忽略文字),找不到符合条件的父(祖先)节点,则相对浏览器窗口进行定位。没有设置了TRBL则默认浮动,默认浮动在父级节点的content-box区。

  1. <style lang="stylus" rel="stylesheet/stylus">
  2. @import "../../common/stylus/mixin"
  3. .header
  4. position: relative
  5. color: #fff
  6. background: #999
  7. .content-wrapper
  8. position: relative
  9. font-size 0px
  10. padding: 24px 12px 18px 24px

 

二、显示区域文字超出显示…

  1. white-space: nowrap
    overflow: hidden
    text-overflow: ellipsis
  1. font-size:0 影响省略号,不能使用

  1. 另外不显示文字
  1. <div class="bulletin-wrapper" @click="showDetail">

   因为还没定义showDetail,所以要暂时先把

  1. @click="showDetail"删掉。

三、模糊背景图片

  1. <style lang="stylus" rel="stylesheet/stylus">
  2. @import "../../common/stylus/mixin"
  3. .header
  4. position: relative
  5. color: #fff
  6. background: rgba(7, 17, 27, 0.5)
  7. .content-wrapper
  1. .background
  2. position: absolute
  3. top: 0
  4. left: 0
  5. width: 100%
  6. height: 100%
  7. z-index: -1
  8. filter: blur(10px)
  1. <div class="background">
  2. <img :src="seller.avatar" width="100%" height="100%">
  3. </div>

通过一个半透明的颜色层覆盖在一个滤镜模糊图片上实现。

 四、点击事件

  1. <div v-if="seller.supports" class="support-count" @click="showDetail">
  2. <span class="count">{{seller.supports.length}}个</span>
  3. <i class="icon-keyboard_arrow_right"></i>
  4. </div>
  1. <div class="detail" v-show="detailShow"></div>

detailShow相当于一个开关量

  1. export default {
  2. props: {
  3. seller: {
  4. type: Object
  5. }
  6. },
  7. name: \'Vheader\',
  8. data() {
  9. return {
  10. detailShow: false
  11. }
  12. },
  13. methods: {
  14. showDetail() {
  15. this.detailShow = true
  16. },
  17. hideDetail() {
  18. this.detailShow = false
  19. }
  20. }
  21. }

这样就可以点击时就可以显示detail

五、显示关闭按钮

需要注意一点的是,要在main.js中导入,注意红色部分,否则不显示,另外要./,否则出错

  1. // The Vue build version to load with the `import` command
  2. // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
  3. import Vue from \'vue\'
  4. import App from \'./App\'
  5. import router from \'./router\'
  6. import VueResource from \'vue-resource\'
  7. import \'./common/stylus/index.styl\'
  8. Vue.config.productionTip = false
  9. Vue.use(VueResource)
  10. /* eslint-disable no-new */
  11. new Vue({
  12. el: \'#app\',
  13. router,
  14. components: { App },
  15. template: \'<App/>\'
  16. })

 

 另外为了实现自适应内容,要在容器div上加clearfix

版权声明:本文为zhaogaojian原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/zhaogaojian/p/8589897.html