css实现带有阴影效果的图文卡片点击展开更多详情效果代码
代码语言:html
所属分类:布局界面
代码描述:css实现带有阴影效果的图文卡片点击展开更多详情效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> @import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap"); *, *::before, *::after { box-sizing: border-box; } .main { max-width: 1200px; margin: 0 auto; font-family: "Poppins", sans-serif; } .main .cards { display: flex; flex-wrap: wrap; list-style: none; margin: 0; padding: 0; } .main .cards_item { display: flex; padding: 1rem; } .main .cards_item .card { background-color: white; border-radius: 0.5rem; box-shadow: 0 20px 40px -14px rgba(0, 0, 0, 0.25); display: flex; flex-direction: column; overflow: hidden; position: relative; height: fit-content; padding: 0 0 2rem 0; position: relative; } .main .cards_item .card.truncate .card_text { overflow: hidden; max-height: 8rem; -webkit-box-orient: vertical; display: block; display: -webkit-box; overflow: hidden !important; text-overflow: ellipsis; -webkit-line-clamp: 4; } .main .cards_item .card.truncate .more { transform: rotate(180deg); } .main .cards_item .card .card_image { max-height: 250px; } .main .cards_item .card .card_content { padding: 1rem; } .main .cards_item .card .card_content .card_title { margin: 0.5rem 0; } .main .cards_item .card .card_content .card_text { margin: 0; } .main .cards_item .card .card_content .card_text .note { position: absolute; top: 1rem; right: 1rem; background: #ffffff95; font-weight: 600; border-radius: 0.1rem; padding: 0.1rem 0.5rem; text-transform: uppercase; } .main .cards_item .card .more { cursor: pointer; position: absolute; bottom: 0.25rem; display: flex; width: 100%; align-items: center; justify-content: center; text-align: center; } .main .cards_item .card .more:hover { color: #555; } .md { font-weight: 500; } @media (min-width: 40rem) { .cards_item { width: 50%; } } @media (min-width: 56rem) { .cards_item { width: 33.3333%; } } .material-icons { font-family: "Material Icons"; font-weight: normal; font-style: normal; font-size: 1.5rem; /* Preferred icon size */ display: inline-block; line-height: 1; text-transform: none; letter-spacing: normal; word-wrap: normal; white-space: nowrap; direction: ltr; /* Support for all WebKit browsers. */ -webkit-font-smoothing: antialiased; /* Support for Safari and Chrome. */ text-rendering: optimizeLegibility; /* Support for Firefox. */ -moz-osx-font-smoothing: grayscale; /* Support for IE. */ font-feature-settings: "liga"; } </style> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> </head> <body> <div class="main"> <ul class="cards"> <li class="cards_item"> <div class="card truncate" id="farmstandSalad"> <div class="card_image"><img src="//repo.bfw.wiki/bfwrepo/image/5e62ef20b92ee.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_400,h_250,/quality,q_90" alt="mixed vegetable salad in a mason jar. "></div> <div class="card_content"> <h2 class="card_title">Farmstand Salad • $9</h2> <div class="card_text "> .........完整代码请登录后点击上方下载按钮下载查看
网友评论0