123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254 |
- <template>
- <!-- 滑块 -->
- <div class="slider">
- <!-- 标题部分 -->
- <div class="scienceTitle">
- <h5>三农科教</h5>
- <p class="title">
- <span v-for="(item, index) in scienceTitleList" :key="index" @mousemove="changeUl(index)">
- <a href="#">{{ item.title }}</a>
- </span>
- </p>
- </div>
- <!-- 标题下内容列表 -->
- <div class="box">
- <transition name="fade">
- <div class="scienceListBox">
- <ul class="scienceList">
- <li v-for="item in 6">
- <img src="../../static/images/sgbhsihfgisdfaasda45632113_A_Chinese_farmer_carrying_a_hoe_is_h_a23e4b96-a6d7-49e1-a283-68c395f277f9.png"
- alt="">
- <p>市农业农村局关于印发连云港市市级…</p>
- </li>
- </ul>
- <ul class="scienceList">
- <li v-for="item in 6">
- <img src="../../static/images/sgbhsihfgisdfaasda45632113_A_Chinese_farmer_carrying_a_hoe_is_h_1ba32eee-c498-4dd7-9cd9-013568c09db7.png"
- alt="">
- <p>市农业农村局关于印发连云港市市级…</p>
- </li>
- </ul>
- <ul class="scienceList">
- <li v-for="item in 6">
- <img src="../../static/images/rgmezdvz_19982_On_a_vast_and_boundless_wheat_field_many_harvest_5b5cfeda-ef17-4551-a935-5f8e3f799b69.png"
- alt="">
- <p>市农业农村局关于印发连云港市市级…</p>
- </li>
- </ul>
- <ul class="scienceList">
- <li v-for="item in 6">
- <img src="../../static/images/rgmezdvz_19982_A_Chinese_farmer_carrying_a_hoe_is_hoeing_the_fi_a036c7b3-b05e-4d3d-a371-0bed91ec1ff8(1).png"
- alt="">
- <p>市农业农村局关于印发连云港市市级…</p>
- </li>
- </ul>
- </div>
- </transition>
- </div>
- </div>
- </template>
- <script setup>
- let scienceTitleList = [
- {
- id: 1,
- title: "农产畅销"
- },
- {
- id: 2,
- title: "农业在线"
- },
- {
- id: 3,
- title: "农产行情"
- },
- {
- id: 4,
- title: "名优特产"
- }
- ]
- //鼠标移入标题时,下方内容会发生变化
- let changeUl = (index) => {
- // console.log(index);
- if (process.browser) {
- let scienceListBox = document.querySelector('.scienceListBox');
- let titleList = document.querySelectorAll('.title>span>a')
- for (let i = 0; i < titleList.length; i++) {
- titleList[i].className = ''
- }
- titleList[index].setAttribute('class', 'current')
- if (index == 0) {
- scienceListBox.style.left = 0
- } else if (index == 1) {
- scienceListBox.style.left = "-790px"
- } else if (index == 2) {
- scienceListBox.style.left = "-1580px"
- } else if (index == 3) {
- scienceListBox.style.left = "-2370px"
- }
- }
- }
- </script>
- <style lang="less" scoped>
- // 标题
- .scienceTitle {
- height: 37px;
- h5 {
- float: left;
- width: 96px;
- height: 34px;
- font-family: PingFang SC, PingFang SC;
- font-weight: 600;
- font-size: 24px;
- color: #000000;
- line-height: 28px;
- text-align: left;
- font-style: normal;
- text-transform: none;
- margin-right: 20px;
- }
- >p {
- float: left;
- height: 37px;
- line-height: 30px;
- >span {
- display: inline-block;
- height: 20px;
- line-height: 20px;
- text-align: center;
- margin: 4px 0px 3px;
- padding: 0 20px;
- border-right: 1px solid #ccc;
- >a {
- display: inline-block;
- padding-bottom: 11px;
- font-family: PingFang SC, PingFang SC;
- font-weight: 500;
- font-size: 20px;
- color: #666666;
- line-height: 20px;
- font-style: normal;
- text-transform: none;
- box-sizing: border-box;
- }
- .current {
- color: #139602;
- border-bottom: 1px solid #139602;
- }
- }
- >span:nth-child(4) {
- border-right: none;
- }
- >span:hover>a {
- color: #139602;
- border-bottom: 1px solid #139602;
- }
- }
- }
- .box {
- width: 790px;
- height: 570px;
- position: relative;
- overflow: hidden;
- }
- .fade-in{
- animation: fadeIn 1s ease-in-out;
- }
- .fade-enter-from,
- .fade-leave-to {
- opacity: 0;
- }
- .fade-enter-to,
- .fade-leave-from {
- opacity: 1;
- }
- .fade-enter-active,
- .fade-leave-active {
- transition: opacity 1s ease;
- }
- .scienceListBox {
- width: 3160px;
- height: 570px;
- position: absolute;
- top: 0;
- left: 0;
- transition: all 3s linear 0;
- }
- // 标题下列表
- .scienceList {
- width: 790px;
- height: 570px;
- float: left;
- margin-top: 17px;
- >li {
- width: 250px;
- height: 276px;
- float: left;
- margin-right: 20px;
- position: relative;
- >img {
- width: 250px;
- height: 220px;
- }
- >p {
- height: 56px;
- width: 248px;
- font-family: PingFang SC, PingFang SC;
- font-weight: 600;
- font-size: 18px;
- color: #333333;
- line-height: 24px;
- text-align: left;
- font-style: normal;
- text-transform: none;
- }
- >p:hover {
- color: #139602;
- }
- }
- >li:nth-child(3),
- >li:nth-child(6) {
- margin-right: 0;
- }
- >li::before {
- content: "";
- display: inline-block;
- width: 40px;
- height: 20px;
- position: absolute;
- top: 0;
- right: 0;
- background-image: url("../../static/images/Component 209.png");
- }
- }
- </style>
|