html语言中从左到右的滚动代码是啥求指教

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html语言中从左到右的滚动代码是啥求指教相关的知识,希望对你有一定的参考价值。

如题

参考技术A 如果只是文字滚动
<marquee>你要滚动的文字</marquee>
如果是图片带文字滚动,把下面的代码复制到你需要这个效果的地方,修改掉图片的路径,即可。
<!--滚动图开始-->
<div id="my_demo">
<div id="my_indemo">
<div id="my_demo1">

<a href="/gongsixiangce/277.html"><img src="/uploadfile/201302/18/1655566609.jpg" alt="营业执照" title="营业执照" border="0" />
<span>营业执照</span></a>
<a href="/gongsixiangce/276.html"><img src="/uploadfile/201302/26/1628166281.jpg" alt="公司相册" title="公司相册" border="0" />
<span>公司相册</span></a>
<a href="/gongsixiangce/275.html"><img src="/uploadfile/201302/26/1628377609.jpg" alt="公司相册" title="公司相册" border="0" />
<span>公司相册</span></a>
<a href="/gongsixiangce/274.html"><img src="/uploadfile/201302/26/1628466845.jpg" alt="公司相册" title="公司相册" border="0" />
<span>公司相册</span></a>
<a href="/gongsixiangce/273.html"><img src="/uploadfile/201302/26/1628566893.jpg" alt="公司相册" title="公司相册" border="0" />
<span>公司相册</span></a>
<a href="/gongsixiangce/272.html"><img src="/uploadfile/201302/26/162988469.jpg" alt="公司相册" title="公司相册" border="0" />
<span>公司相册</span></a>
<a href="/gongsixiangce/265.html"><img src="/uploadfile/201302/26/1629200329.jpg" alt="公司相册" title="公司相册" border="0" />
<span>公司相册</span></a>
<a href="/gongsixiangce/264.html"><img src="/uploadfile/201302/26/1629388877.jpg" alt="公司相册" title="公司相册" border="0" />
<span>公司相册</span></a>

</div>
<div id="my_demo2"></div>
</div>
</div>
<script>
<!--
var my_speed=20;
var my_tab=document.getElementById("my_demo");
var my_tab1=document.getElementById("my_demo1");
var my_tab2=document.getElementById("my_demo2");
my_tab2.innerHTML=my_tab1.innerHTML;
function my_Marquee()
if(my_tab2.offsetWidth-my_tab.scrollLeft<=0)
my_tab.scrollLeft-=my_tab1.offsetWidth
else
my_tab.scrollLeft++;


var my_MyMar=setInterval(my_Marquee,my_speed);
my_tab.onmouseover=function() clearInterval(my_MyMar);
my_tab.onmouseout=function() my_MyMar=setInterval(my_Marquee,my_speed);
-->
</script>
<!--滚动图开始-->本回答被提问者采纳
参考技术B <marquee>Hello, World</marquee> 参考技术C /left/left 参考技术D <marquee></marquee>
这个标签,有好几个属性都是可以美化一下,无论文字还是图片都可以
第5个回答  2013-08-24 这个应该是比较好实现的才对,不过你说的不是很清楚哈。
怎么个滚动法呢?你能再描述下么?
或者你直接Q我,我给你细说也好。Q号的话,我的资料里有写的。

升级到 Swift 3.0 后从左到右的动画不起作用

【中文标题】升级到 Swift 3.0 后从左到右的动画不起作用【英文标题】:Left to right animation not working after upgrade to Swift 3.0 【发布时间】:2016-10-07 20:33:36 【问题描述】:

所以我刚刚从 2.3 升级到 Swift 3.0。除了这行代码及其错误之外,关于我的项目的其他一切都很好:

        if let delegate: AnyObject = completionDelegate 
        leftToRightTransition.delegate = delegate //ERROR MESSAGE
    

错误信息说:

无法将“AnyObject”类型的值赋给 CAAnimation 类型

下面是完整的相关代码块。本质上,这段代码就是动画。在我的项目的其他地方(我很肯定这与问题无关,而只是为了上下文)有代码允许用户在一组图像中滑动。这个块是它的动画部分('滑动'动画'):

extension UIView 
func rightToLeftAnimation(_ duration: TimeInterval = 0.5, completionDelegate: AnyObject? = nil) 
    // Create a CATransition object
    let rightToLeftTransition = CATransition()

    // Set its callback delegate to the completionDelegate that was provided
    if let delegate: AnyObject = completionDelegate 
        rightToLeftTransition.delegate = delegate //ERROR MESSAGE ON THIS LINE
    

    rightToLeftTransition.type = kCATransitionPush
    rightToLeftTransition.subtype = kCATransitionFromLeft
    rightToLeftTransition.duration = duration
    rightToLeftTransition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
    rightToLeftTransition.fillMode = kCAFillModeRemoved

    // Add the animation to the View's layer
    self.layer.add(rightToLeftTransition, forKey: "rightToLeftTransition")

这在 Swift 2.3 中工作得很好,但现在它不起作用了。像这样的小东西让我发疯......任何帮助将不胜感激;)

【问题讨论】:

哇,伙计们!感谢您的超快速答案,我很感激。我确信这两个答案都会奏效,但我尝试了 Rob's 并且它奏效了。非常感谢大家! 【参考方案1】:

现在是CAAnimationDelegate:

if let delegate = completionDelegate as? CAAnimationDelegate 
    rightToLeftTransition.delegate = delegate

或者只是:

func rightToLeftAnimation(_ duration: TimeInterval = 0.5, completionDelegate: CAAnimationDelegate? = nil) 
    // Create a CATransition object
    let rightToLeftTransition = CATransition()

    // Set its callback delegate to the completionDelegate that was provided
    rightToLeftTransition.delegate = completionDelegate

    rightToLeftTransition.type = kCATransitionPush
    rightToLeftTransition.subtype = kCATransitionFromLeft
    rightToLeftTransition.duration = duration
    rightToLeftTransition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
    rightToLeftTransition.fillMode = kCAFillModeRemoved

    // Add the animation to the View's layer
    layer.add(rightToLeftTransition, forKey: "rightToLeftTransition")

【讨论】:

【参考方案2】:
Try this , Its working in my code:

 let swipeRight:UISwipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(ViewController.swipedRight))
        swipeRight.direction = .right
        SLIDEVIEW.addGestureRecognizer(swipeRight)


        let swipeLeft:UISwipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(ViewController.swipedLeft))
        swipeLeft.direction = .left
        SLIDEVIEW.addGestureRecognizer(swipeLeft)

func swipedRight()
    
        print("swiped right")
        updateFrames(towards: "right")
    

    func swipedLeft()
    
        print("swiped left")
        updateFrames(towards: "left")
    

【讨论】:

以上是关于html语言中从左到右的滚动代码是啥求指教的主要内容,如果未能解决你的问题,请参考以下文章

当滚动方向为水平时,从左到右填充 UICollectionView

用HTML语言怎样使图片连续的从左到右滚动

如何以编程方式在 iPhone 应用程序中从左到右移动文本? [关闭]

如何防止在水平滚动方向上从左到右滚动集合视图?

iOS 用从左到右的动画取消隐藏视图

jqgrid - 水平滚动条 - 位置 - 分页后 - 从左到右