B2主题美化 首页增加动态滚动公告显示订单信息

文章最后更新时间:2024-02-02 19:02:45

滚动的公告信息,能很好的展示会员信息,可以展示订单等内容,需要的自行下载测试,修改前备份数据,该美化有用到jquery请自行引入,如您已经引入过则可以忽视。

图片[1] - B2主题美化 首页增加动态滚动公告显示订单信息

第一步

在合适的位置插入以下HTML代码

 <div id="rizhuti_v2_module_dynamic-5" class="section rizhuti_v2-widget-dynamic">
  <div class="wrapper">
    <div class="module owl-dynamic alert-primary">
      <span class="d-none d-lg-block float-left">
        <span class="badge badge-danger mr-2">
          <i class="b2font b2-notification-3-line"></i>网站动态
          </span>
      </span>
      <div class="scroll-dynamic" id="scroll-dynamic">
        <ul style="margin-top: 0px;">
          
         <?php
$arr=B2Danmu_allinfo_data($data);
    
    foreach($arr as $row){
       
        foreach($row as $cell){
            echo '<li>'.$cell.'</li>';
        }
        
    }
;
?>
        </ul>
      </div>
      <span class="float-right d-none d-lg-block">
             <small class="mr-2">用户
          <span class="badge badge-primary-lighten ml-1"><?php $users = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users"); echo $users; ?></span></small>
        <small class="mr-2">文章
          <span class="badge badge-primary-lighten ml-1"><?php $count_posts = wp_count_posts(); echo $published_posts = $count_posts->publish;?></span></small>
        <small class="mr-2">评论
          <span class="badge badge-primary-lighten ml-1"><?php echo $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments");?></span></small>
        <small class="mr-2">建站
          <span class="badge badge-primary-lighten ml-1"><?php echo floor((time()-strtotime("2023-11-01"))/86400); ?>天</span></small>
      </span>
    </div>
     
  </div>
</div>    
 
  <script>
      function autoscroll(obj){
 
                                     
 
          $(obj).find("ul:first").animate({marginTop:"-25px"},1000,function(){
              $(this).css("marginTop","0px").find("li:first").appendTo(this)
           })
       }
 $(document).ready(function(){
      setInterval('autoscroll("#scroll-dynamic")',1500)
 })
</script>

第二步

在自定义css中添加以下CSS代码

在自定义css中添加以下CSS代码

/*网站动态开始*/@media screen and (max-width: 768px){
    .owl-dynamic .scroll-dynamic ul li {
        width: 280px!important; /* 设置容器宽度 */        overflow: hidden; /* 当内容超出容器宽度时进行隐藏 */        white-space: nowrap; /* 不换行 */         
}
 .float-left,.float-right{
     display:none!important;
 }   
    .owl-dynamic .scroll-dynamic{
        max-width:unset!important;
    }
     
}
.mr-2, .mx-2 {
    margin-right: 0.5rem!important;
}
 
.badge-danger {
    color: #f46;
    background-color: rgba(255, 68, 102, 0.15);
}
.badge {
    display: inline-block;
    padding: 0.2em 0.6em;
    font-size: 75%;
    font-weight: 700;
    line-height: 2;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.25rem;
    transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}
.float-left {
    float: left;
}
 
.d-lg-block {
    display: block;
}
#rizhuti_v2_module_dynamic-5{
    margin-bottom:20px;
}
#rizhuti_v2_module_dynamic-5 .owl-dynamic {
    color: #000;
   background: #fff;
     
}
#rizhuti_v2_module_dynamic-5 .owl-dynamic {
    position: relative;
    padding: 10px 15px;
    border-radius: 0.5rem;
}
.ml-1, .mx-1 {
    margin-left: 0.25rem!important;
}
.spinner-grow-sm {
    width: 1rem;
    height: 1rem;
}
.spinner-grow {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    vertical-align: text-bottom;
    background-color: currentColor;
    border-radius: 50%;
    opacity: 0;
    -webkit-animation: .75s linear infinite spinner-grow;
    animation: .75s linear infinite spinner-grow;
}
.small, small {
    font-size: 96%;
    font-weight: 400;
    color: #000;
    line-height: 2;
}
sup {
    top: -0.5em;
}
sub, sup {
    position: relative;
    font-size: 75%;
    line-height: 0;
    vertical-align: baseline;
}
 .spinner-border,
  .spinner-grow {
    -webkit-animation-duration: 1.5s;
    animation-duration: 1.5s;
  }
 
.owl-dynamic .scroll-dynamic {
    height: 25px;
    line-height: 25px;
    overflow: hidden;
    display: inline-block;
    max-width: 64%;
}
 
.owl-dynamic .scroll-dynamic ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.owl-dynamic .scroll-dynamic ul li {
    font-size:16px;
    font-weight: 600;
    height: 25px;
    padding-left: 0;
    line-height: 30px;
    white-space: nowrap; /* 防止换行 */        overflow: hidden; /* 超过部分隐藏 */        width:500px;
}
.owl-dynamic .scroll-dynamic ul li a{
    color:#f46;
   text-decoration:underline;
}
.dark-open a {
    color: #fff;
}
.float-right {
    float: right;
}
 
 
.d-lg-block {
    display: block;
}
.mr-2, .mx-2 {
    margin-right: 0.5rem!important;
}
.small, small {
    font-size: 16px;
    font-weight: 400;
    color: #000;
    line-height: 2;
}
small {
    font-size: 80% !important;
}
.badge-primary-lighten {
    color: #f46;
    background-color: rgba(255, 68, 102, 0.15);
    margin-bottom: 10px;
}
.ml-1, .mx-1 {
    margin-left: 0.25rem!important;
}
 
.badge {
    display: inline-block;
    padding: 0.2em 0.6em;
    font-size: 14px;
    font-weight: 700;
    line-height: 24px;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.25rem;
    transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}
/*网站动态结束*/

第三步

在主题functions.php中添加以下代码

THE END
点赞11 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容