flex 简单跑马灯效果(竖着显示)

<mx:Move id="move_area" target="{VBox_AreaWarning}"/>   //move效果,模拟跑马灯

<s:BorderContainer   borderVisible="false" height="80" >
      <s:BorderContainer id="border_area" top="15" height="100%"
             borderVisible="false">
       <s:layout>       //flex4的layout还是很好用的,没那么麻烦
        <s:VerticalLayout paddingBottom="0" paddingLeft="0" paddingRight="0" paddingTop="0" gap="0" clipAndEnableScrolling="true"   >      //clipAndEnableScrolling必须为true否则内容会跑出范围
        </s:VerticalLayout>
       </s:layout>
        <mx:VBox id="VBox_AreaWarning" x="0" mouseOver="VBox_AreaWarning_mouseOverHandler(event)" mouseOut="VBox_AreaWarning_mouseOutHandler(event)">    //把跑马灯的内容放进vbox里,尤其适合多条记录同时滚动的效果 
        
        </mx:VBox>
      </s:BorderContainer>
      <s:Label x="10" y="0" fontFamily="宋体" fontWeight="bold" text="【区域告警】"/>
     </s:BorderContainer>

这里画出一个bordercontainer,在里面做跑马灯效果

move_area.yFrom = border_area.height;    
     move_area.yTo =  -x.length*15;   //如果动态载入内容,推荐根据记录条数去算y移动到的位置,vbox的高度是算不出来的,静态的直接用高度吧
     move_area.repeatCount = 0; //loop 
     move_area.repeatDelay = 0; //loop time 
     move_area.duration = 6000; //the time of scroll once 
     move_area.play();

必须为move_area添加以上属性用以循环

//mouseover时停止滚动

protected function VBox_AreaWarning_mouseOverHandler(event:MouseEvent):void
   {
    move_area.pause();
   } 

//mouseout时从停止的地方继续
   protected function VBox_AreaWarning_mouseOutHandler(event:MouseEvent):void
   {
    move_area.resume();
   }

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要使用flex布局实现跑马灯效果,可以按照以下步骤进行操作: 1. 首先,在HTML中创建一个具有固定宽度和高度的容器,例如div标签,并赋予其一个唯一的类名,比如"carousel-container"。 2. 在该容器内,创建一个包含图片的子容器,例如ul标签,并赋予其一个唯一的类名,比如"carousel-list"。 3. 在"carousel-list"容器中,使用flex布局将其子元素水平排列。可以通过设置"display: flex"和"flex-direction: row"来实现。 4. 确保每个子元素都具有相同的宽度和高度,以便它们能够在同一行中显示。 5. 对于在跑马灯显示的图片,可以使用img标签将其包裹,并设置适当的宽度和高度。 6. 使用JavaScript或Vue等框架,将图片的URL存储在一个数组中。 7. 使用循环语句(如v-for)遍历该数组,并为每个图片创建一个列表项(li标签)。 8. 在CSS中,为"carousel-container"容器设置合适的宽度和高度,以及overflow属性为hidden,以确保只显示容器内部的内容。 9. 使用CSS的animation属性和@keyframes规则,实现图片在容器内水平滚动的动画效果。 10. 最后,通过调整动画的持续时间和延迟时间,以及设置无限循环,来实现完整的跑马灯效果。 下面是一个使用flex布局实现跑马灯效果的示例代码: HTML: ```html <div class="carousel-container"> <ul class="carousel-list"> <li v-for="(image, index) in carouselImages" :key="index"> <img :src="image" alt="carousel-image" width="200px" height="200px"> </li> </ul> </div> ``` CSS: ```css .carousel-container { width: 100%; height: 200px; overflow: hidden; } .carousel-list { display: flex; flex-direction: row; animation: carousel-animation 10s infinite linear; } .carousel-list li { width: 200px; height: 200px; margin-right: 10px; } @keyframes carousel-animation { 0% { transform: translateX(0); } 100% { transform: translateX(-100%); } } ``` JavaScript/Vue: ```javascript export default { data() { return { carouselImages: [ "https://t1.picb.cc/uploads/2019/05/30/giNfLi.md.jpg", "https://i.loli.net/2019/05/29/5cee3e9cd3a1a11937.jpg", "https://i.loli.net/2019/05/29/5cee3f031451617189.jpg", "https://i.loli.net/2019/05/29/5cee3f032577c34451.jpg", "https://i.loli.net/2019/05/29/5cee3f78e138834786.jpg", "https://i.loli.net/2019/05/29/5cee3f78e644247723.jpg" ] }; } }; ``` 这样,你就可以使用flex布局实现一个简单跑马灯效果。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [flex布局实现上下固定中间滑动的布局方式](https://download.csdn.net/download/weixin_38702515/13127966)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [Element-ui初探——容器、走马灯、flex布局](https://blog.csdn.net/weixin_41777814/article/details/115130520)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值