html原生标签,原生html详情标签(details)用法示例

这篇博客展示了如何利用CSSSCSS预处理器来导入IBM Plex Sans字体,并创建一个带有自定义颜色主题的响应式卡片组件。卡片包括了不同类型的细节展示,如警告、信息和提醒,通过改变背景色和边框颜色来区分。此外,还详细介绍了如何使用`var()`函数来实现变量复用,以及如何为`details`和`summary`元素添加交互效果。
摘要由CSDN通过智能技术生成

CSS

语言:

CSSSCSS

确定

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700&display=swap');

:root {

--color-bg: #FEFDFB;

--color-title: #0E1C4E;

--color-summary-1: #FFF6EE;

--color-summary-1-highlight: #FFC48B;

--color-summary-2: #FAFAFF;

--color-summary-2-highlight: #B4B3FF;

--color-summary-3: #FFF0F3;

--color-summary-3-highlight: #FFB3C0;

--font-ibm-plex-sans: 'IBM Plex Sans', sans-serif;

}

html,

body {

overflow: auto;

height: 100vh;

width: 100%;

background: var(--color-bg);

display: flex;

align-items: center;

justify-content: center;

}

.card {

background: white;

padding: 38px 36px;

margin-top: 40px;

margin-bottom: 40px;

border-radius: 4px;

box-shadow: 0 8px 10px rgba(0, 0, 0, .1);

max-width: 400px;

width: 100%;

h1 {

font-family: var(--font-ibm-plex-sans);

font-style: normal;

font-weight: bold;

font-size: 18px;

line-height: 1.2;

color: var(--color-title);

margin-bottom: 20px;

}

details {

border-radius: 4px;

overflow: hidden;

padding: 20px;

background: rgba(0, 0, 0, .05);

border-left: 5px solid gray;

&:not(:last-of-type) {

margin-bottom: 15px;

}

&.warning {

background: var(--color-summary-1);

border-left: 5px solid var(--color-summary-1-highlight);

}

&.info {

background: var(--color-summary-2);

border-left: 5px solid var(--color-summary-2-highlight);

}

&.alert {

background: var(--color-summary-3);

border-left: 5px solid var(--color-summary-3-highlight);

}

summary,

p {

font-family: var(--font-ibm-plex-sans);

font-style: normal;

font-weight: normal;

font-size: 14px;

line-height: 1.4;

color: var(--color-title);

&:not(:last-of-type) {

margin-bottom: 10px;

}

}

p {

padding-left: 30px;

}

summary {

cursor: pointer;

margin-bottom: 0;

list-style-image: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M22.6066 12H1.3934' stroke='%23202842' stroke-width='1.875' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M12 1.39343V22.6066' stroke='%23202842' stroke-width='1.875' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E%0A");

&::-webkit-details-marker {

background-image: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M22.6066 12H1.3934' stroke='%23202842' stroke-width='1.875' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M12 1.39343V22.6066' stroke='%23202842' stroke-width='1.875' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E%0A");

color: transparent;

background-size: 100% 100%;

margin-right: 18px;

width: 16px;

height: 16px;

transform: translateY(2px);

}

}

&[open] {

summary {

margin-bottom: 10px;

list-style-image: url("data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 18 18' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M16.5 16.5L1.5 1.5' stroke='%23202842' stroke-width='1.875' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M16.5 1.5L1.5 16.5' stroke='%23202842' stroke-width='1.875' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E%0A");

font-weight: 700;

&::-webkit-details-marker {

background-image: url("data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 18 18' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M16.5 16.5L1.5 1.5' stroke='%23202842' stroke-width='1.875' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M16.5 1.5L1.5 16.5' stroke='%23202842' stroke-width='1.875' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E%0A");

color: transparent;

background-size: 100% 100%;

margin-right: 20px;

width: 12px;

height: 12px;

transform: translateY(1px);

}

}

p {

padding-left: 32px;

}

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在React中实现Vue中的v-html效果,可以使用dangerouslySetInnerHTML属性。这个属性可以直接将HTML字符串插入到React组件中。使用原生操作,可以通过useState来存储HTML字符串,并在函数组件中使用dangerouslySetInnerHTML来渲染这个字符串。下面是一个示例代码: ```jsx import React, { useState } from 'react'; function App() { let [htmlString, setHtmlString = useState("<h1>hello world</h1>"); return ( <div dangerouslySetInnerHTML={{ __html: htmlString }}></div> ); } export default App; ``` 在这个示例中,我们使用useState来定义一个名为htmlString的状态变量,并将初始值设置为"<h1>hello world</h1>"。然后,在组件的返回部分,我们使用dangerouslySetInnerHTML属性来渲染这个htmlString变量的内容。 需要注意的是,在使用dangerouslySetInnerHTML属性时,需要将HTML字符串包装在一个对象中,并将该对象传递给dangerouslySetInnerHTML属性的__html属性。这是为了强调这是一个有意为之的危险操作,需要小心使用。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [在React中实现Vue中的v-html效果](https://blog.csdn.net/weixin_53452096/article/details/119042629)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *3* [原生java影视app源码 对接苹果cms](https://download.csdn.net/download/weixin_36643308/88250409)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值