编辑代码

<?php  
// 假设这是从数据库或其他来源获取的带链接的文字列表  
$links = [  
    ["text" => "第1个链接:府城卫生院党建", "url" => "/home.php"],  
    ["text" => "第2个链接:府城卫生院日常", "url" => "/about.php"],  
    ["text" => "第3个链接:府城卫生院创新", "url" => "/products.php"],  
    ["text" => "第4个链接:府城卫生院活动", "url" => "/contact.php"],  
    // 可以根据需要添加更多项  
];  
  
// 生成HTML代码  
echo '<div class="scroll-container">';  
foreach ($links as $link) {  
    echo '<a href="'.$link['url'].'" class="scroll-item">'.$link['text'].'</a> ';  
}  
echo '</div>';  
  
// CSS样式,通常放在<head>中的<style>标签内,或外部CSS文件中  
?>  
<style>  
.scroll-container {  
    width: 100%; /* 容器宽度 */  
    overflow: hidden; /* 隐藏溢出的内容 */  
    white-space: nowrap; /* 防止文字换行 */  
    box-sizing: border-box;  
    position: relative; /* 设定相对定位以便内部元素可以绝对定位 */  
    height: 500px; /* 设定一个高度,确保滚动效果 */  
    line-height: 50px; /* 垂直居中文字 */  
    animation: scroll 10s linear infinite; /* 动画效果 */  
}  
  
.scroll-item {  
    display: block; /* 使得每个链接都垂直显示 */  
    padding: 5px 20px; /* 链接之间的间隔和内部填充 */  
    text-decoration: none; /* 去除下划线 */  
    color: yellow; /* 文字颜色 */ 
    backgroud-color: blue; /* 文字颜色 */ 
    /* 其他样式,如边框、背景色等 */  
}  

 
@keyframes scroll {  
    from {  
        transform: translateY(100%); /* 开始时,链接在容器右侧之外 */  
    }  
    to {  
        transform: translateY(-100%); /* 结束时,链接在容器左侧之外 */  
    }   
 
}  
</style>