Procházet zdrojové kódy

美化了页面二

何何何 před 1 rokem
rodič
revize
8b9fa4763b

+ 42 - 2
paint-app/src/app/tab2/tab2.page.html

@@ -7,7 +7,47 @@
 </ion-header>
 
 <ion-content [fullscreen]="true">
-  <ion-card>
+  <ion-segment>
+    <ion-segment-button value="first" content-id="first">
+      <ion-label>热门推荐</ion-label>
+    </ion-segment-button>
+    <ion-segment-button value="second" content-id="second">
+      <ion-label>名家作品</ion-label>
+    </ion-segment-button>
+    <ion-segment-button value="third" content-id="third">
+      <ion-label>视频教学</ion-label>
+    </ion-segment-button>
+  </ion-segment>
+  <ion-segment-view>
+    <ion-segment-content id="first">
+
+      <div class="image-container">
+        <div class="image-wrapper">
+            <img src="../../assets/icon/tou1.jpg" alt="Image 1" />
+            <a href="#" class="transparent-button">查看介绍</a>
+            <div class="description-box">这是图片1的简单介绍。</div>
+        </div>
+        <div class="image-wrapper">
+            <img src="../../assets/icon/tou2.png" alt="Image 2" />
+            <a href="#" class="transparent-button">查看介绍</a>
+            <div class="description-box">这是图片2的简单介绍。</div>
+        </div>
+        <div class="image-wrapper">
+            <img src="../../assets/icon/bd.jpg" alt="Image 3" />
+            <a href="#" class="transparent-button">查看介绍</a>
+            <div class="description-box">这是图片3的简单介绍。</div>
+        </div>
+        <div class="image-wrapper">
+            <img src="../../assets/icon/favicon.png" alt="Image 4" />
+            <a href="#" class="transparent-button">查看介绍</a>
+            <div class="description-box">这是图片4的简单介绍。</div>
+        </div>
+    </div>
+    </ion-segment-content>
+    <ion-segment-content id="second">Second</ion-segment-content>
+    <ion-segment-content id="third">Third</ion-segment-content>
+  </ion-segment-view>
+  <!-- <ion-card>
     <ion-card-header>
       <ion-card-title>油彩画 <ion-button>查看更多</ion-button></ion-card-title>
     </ion-card-header>
@@ -67,5 +107,5 @@
         </ion-row>
       </ion-grid>
     </ion-card-content>
-  </ion-card>
+  </ion-card> -->
 </ion-content>

+ 102 - 33
paint-app/src/app/tab2/tab2.page.scss

@@ -1,34 +1,103 @@
-.bg-color {
-    --background: #f4f4f4;  /* 设置背景颜色 */
-  }
-  ion-button {
-    --background: white;  /* 设置背景颜色 */
-    --color: #888;
-    --border-radius: 8px; /* 按钮圆角 */
-    font-weight: bold; /* 加粗按钮文本 */
-    height: 40px; /* 按钮高度 */
-    width: auto;
-    float: right;
-    font-size: 16px; /* 设置按钮字体大小 */
-  }
+ion-segment-button ion-label {
+  font-size: 16px; /* 设置字体大小为16px */
+}
+
+// ion-segment-view {
+//   height: 150px;
+// }
+ion-segment-content:nth-of-type(2) {
+  background: lightblue;
+}
+ion-segment-content:nth-of-type(3) {
+  background: lightgreen;
+}
+
+
+/* 容器的样式 */
+.image-container {
+  display: flex;            /* 使用flexbox布局 */
+  flex-wrap: wrap;         /* 允许换行 */
+  gap: 20px;               /* 图片间距,可以根据需要调整 */
+}
+
+/* 每个图片项的样式 */
+.image-wrapper {
+  display: flex;            /* 使用flexbox布局 */
+  flex-direction: column;   /* 垂直排列子元素 */
+  height: auto;            /* 高度自适应 */
+  width: calc(50% - 10px); /* 每个图片占容器的50%宽度,减去间距 */
+  box-sizing: border-box;   /* 确保宽度计算不包括padding */
+  position: relative;       /* 方便调整按钮位置 */
+}
+
+/* 图片的样式 */
+.image-wrapper img {
+  width: 100%;              /* 图片宽度100%,以适应容器 */
+  height: auto;             /* 保持图片比例 */
+}
+
+/* 描述盒子的样式 */
+.description-box {
+  background-color: rgba(255, 255, 255, 0.8); /* 半透明背景 */
+  padding: 10px;            /* 内边距 */
+  border-radius: 5px;      /* 圆角 */
+  margin-top: auto;        /* 自动上边距,使其总是在父盒子底部 */
+  text-align: center;      /* 文字居中 */
+  font-size: 12px;         /* 文字大小 */
+  border: 1px solid #ccc;  /* 添加边界,颜色为浅灰色 */
+}
+
+/* 按钮的样式 */
+.transparent-button {
+  position: absolute;       /* 定位按钮 */
+  bottom: 40px;            /* 距离底部40px,确保在描述盒子上方 */
+  left: 50%;                /* 水平居中 */
+  transform: translateX(-50%); /* 精确居中 */
+  background-color: rgba(255, 255, 255, 0.5); /* 半透明背景 */
+  padding: 10px;            /* 按钮内边距 */
+  text-decoration: none;    /* 移除下划线 */
+  color: black;             /* 按钮文字颜色 */
+  border-radius: 5px;       /* 圆角 */
+  font-size: 14px;          /* 文字大小 */
+  text-align: center;       /* 文字居中 */
+}
+
+.transparent-button:hover {
+  background-color: rgba(255, 255, 255, 0.8); /* 悬停时加深背景色 */
+}
+// .bg-color {
+//     --background: #f4f4f4;  /* 设置背景颜色 */
+//   }
+//   ion-button {
+//     --background: white;  /* 设置背景颜色 */
+//     --color: #888;
+//     --border-radius: 8px; /* 按钮圆角 */
+//     font-weight: bold; /* 加粗按钮文本 */
+//     height: 40px; /* 按钮高度 */
+//     width: auto;
+//     float: right;
+//     font-size: 16px; /* 设置按钮字体大小 */
+//   }
  
-  ion-toolbar {
-    overflow: auto; /* 确保父容器能够包裹浮动元素 */
-  }
-  ion-button:active {
-    --background: #0056b3; /* 按钮按下时的背景颜色 */
-    --color: white; /* 按钮按下时的文本颜色 */
-  }
-
-  ion-img {
-    border-radius: 10px; /* 设置圆角 */
-    margin: 5px; /* 添加间距 */
-    width: 100%; /* 确保图片宽度为100% */
-    height: auto; /* 自适应高度 */
-  }
-
-  ion-card-title {
-    font-size: 24px; /* 设置标题字体大小 */
-    font-weight: bold; /* 设置标题字体加粗 */
-    align-items: center; /* 垂直居中 */
-  }
+//   ion-toolbar {
+//     overflow: auto; /* 确保父容器能够包裹浮动元素 */
+//   }
+//   ion-button:active {
+//     --background: #0056b3; /* 按钮按下时的背景颜色 */
+//     --color: white; /* 按钮按下时的文本颜色 */
+//   }
+
+//   ion-img {
+//     border-radius: 10px; /* 设置圆角 */
+//     margin: 5px; /* 添加间距 */
+//     width: 100%; /* 确保图片宽度为100% */
+//     height: auto; /* 自适应高度 */
+//   }
+
+//   ion-card-title {
+//     font-size: 24px; /* 设置标题字体大小 */
+//     font-weight: bold; /* 设置标题字体加粗 */
+//     align-items: center; /* 垂直居中 */
+//   }
+
+

+ 6 - 7
paint-app/src/app/tab2/tab2.page.ts

@@ -1,5 +1,5 @@
-import { Component } from '@angular/core';
-import { IonHeader, IonToolbar, IonTitle, IonContent } from '@ionic/angular/standalone';
+import { Component,OnInit } from '@angular/core';
+import { IonHeader, IonToolbar, IonTitle, IonContent, IonSegment, IonSegmentContent, IonSegmentView, IonLabel, IonSegmentButton } from '@ionic/angular/standalone';
 import { ExploreContainerComponent } from '../explore-container/explore-container.component';
 import { IonButton, IonCard, IonCardContent, IonCardHeader, IonCardSubtitle, IonCardTitle, IonCol, IonGrid, IonImg, IonRow } from '@ionic/angular/standalone';
 
@@ -9,10 +9,9 @@ import { IonButton, IonCard, IonCardContent, IonCardHeader, IonCardSubtitle, Ion
   styleUrls: ['tab2.page.scss'],
   standalone: true,
   imports: [IonHeader, IonToolbar, IonTitle, IonContent, ExploreContainerComponent,IonButton,
-    IonCard, IonCardContent, IonCardHeader, IonCardSubtitle, IonCardTitle,IonGrid,IonCol,IonRow,IonImg]
+    IonCard, IonCardContent, IonCardHeader, IonCardSubtitle, IonCardTitle,IonGrid,IonCol,IonRow,IonImg
+  ,IonSegment,IonSegmentContent,IonSegmentView,IonLabel,IonSegmentButton]
 })
-export class Tab2Page {
-
-  constructor() {}
-
+export class Tab2Page{
+  constructor(){};
 }