国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
按鈕的定位
按鈕的顏色與形狀
按鈕的圖標(biāo)
按鈕的邊框
按鈕的陰影
懸停樣式
最終效果
Home Web Front-end HTML Tutorial CSS 模擬實(shí)現(xiàn) Material Design 樣式的懸浮操作按鈕_html/css_WEB-ITnose

CSS 模擬實(shí)現(xiàn) Material Design 樣式的懸浮操作按鈕_html/css_WEB-ITnose

Jun 21, 2016 am 08:46 AM

撰寫(xiě)于 2016年6月5日 修改于 2016年6月5日分類(lèi)編程雜記標(biāo)簽前端

Material Design 的懸浮操作按鈕雖然會(huì)擋住一部分頁(yè)面內(nèi)容,但的確提供了一種不錯(cuò)的表現(xiàn)操作按鈕的思路。手里一個(gè)微信的項(xiàng)目正好準(zhǔn)備試試用這種風(fēng)格來(lái)表現(xiàn)創(chuàng)建一類(lèi)的操作。關(guān)于 Material Design 的按鈕介紹,可以看 這里。

這里實(shí)現(xiàn)一個(gè)類(lèi)似于 Gmail App 中的新建郵件按鈕風(fēng)格類(lèi)似的樣式,為了簡(jiǎn)便,就直接使用一個(gè)樣式來(lái)完成,元素的 HTML 如下:

<div class="float-action-button"></div>

按鈕的定位

懸浮操作按鈕一般是位于屏幕的右下方,并且位置不隨網(wǎng)頁(yè)的滾動(dòng)而變化。這可以通過(guò)設(shè)置 position為 fixed來(lái)實(shí)現(xiàn),位置則通過(guò) bottom和 right來(lái)指定。另外還修改一下光標(biāo)的指針樣式:

.float-action-button { position: fixed; right: 20px; bottom: 20px; cursor: pointer;}

按鈕的顏色與形狀

這里的顏色包括四個(gè),分別是:

  • 按鈕的主體背景色
  • 按鈕的邊框顏色
  • 按鈕中鉛筆圖標(biāo)的鉛筆顏色
  • 按鈕的陰影色

其中前兩個(gè)顏色類(lèi)似,而主體色要比邊框色稍微淺一點(diǎn)。如果你有顏色選擇困難癥,可以直接使用 Material Design 顏色推薦表,或者試試這兩個(gè)扁平化設(shè)計(jì)顏色推薦網(wǎng)站: flatuicolorpicker.com、 flatuicolors.com。我用的是 flatuicolorpicker 上的顏色。

圓形通過(guò)設(shè)置 border-radius可以實(shí)現(xiàn),其值大于 50%時(shí)可以表現(xiàn)為圓形。這里借助 padding來(lái)設(shè)置按鈕的大小。

設(shè)置顏色和形狀如下:

.float-action-button { background-color: #D91E18; color: #F2F1EF; border-radius: 50%; padding: 30px;}

按鈕的圖標(biāo)

按鈕中有一個(gè)鉛筆的圖標(biāo),這里為了簡(jiǎn)單,直接使用一個(gè)圖片來(lái)實(shí)現(xiàn)。目前發(fā)現(xiàn)的最豐富的圖標(biāo)資源站,當(dāng)然是 iconfont,搜索 pencil可以找到 258 個(gè)圖標(biāo),挑一個(gè)就行。但要注意,因?yàn)楸尘吧珵樯钌?,為了使鉛筆看起來(lái)相對(duì)明顯一點(diǎn),最好選擇圖標(biāo)中著色面積大的。鼠標(biāo)指向圖標(biāo)可以顯示下載按鈕,著色要與背景色形成對(duì)象,使用白色,或者淺灰,這里直接使用 iconfont 推薦的 #ecf0f1。

背景圖要設(shè)置為居中,不重復(fù)。大小為整個(gè)按鈕大小的一半——將 background-size設(shè)置為 padding值即可。

.float-action-button { background-image: url('./pencil.png'); background-repeat: no-repeat; background-position: center; background-size: 30px;}

按鈕的邊框

按鈕有一個(gè)很細(xì)的邊框,顏色相對(duì)背景色要稍深一點(diǎn),通過(guò) border來(lái)設(shè)置:

.float-action-button { border: 1px solid #CF000F;}

按鈕的陰影

CSS 的陰影有兩種, text-shadow和 box-shadow,前者用于指定文字陰影,這里要使用 box-shadow,它典型的值有五個(gè),分別是x軸偏移、y軸偏移、blur 模糊的半徑、發(fā)散半徑、陰影顏色。懸浮操作按鈕只有 y 軸偏移。而且顏色很淺。

.float-action-button { box-shadow: 0px 3px 9px 2px #BFBFBF;}

懸停樣式

當(dāng)鼠標(biāo)經(jīng)過(guò)和點(diǎn)擊之后,要模板一個(gè)按鈕按下的效果,直接通過(guò)修改背景色和加大陰影 y 軸偏移即可,如下:

.float-action-button:hover { background-color: #F22613; box-shadow: 0px 6px 9px 2px #BFBFBF;}

最終效果

請(qǐng)參見(jiàn)Demo。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1502
276
Implementing Clickable Buttons Using the HTML button Element Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM

To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this

Configuring Document Metadata Within the HTML head Element Configuring Document Metadata Within the HTML head Element Jul 09, 2025 am 02:30 AM

Metadata in HTMLhead is crucial for SEO, social sharing, and browser behavior. 1. Set the page title and description, use and keep it concise and unique; 2. Add OpenGraph and Twitter card information to optimize social sharing effects, pay attention to the image size and use debugging tools to test; 3. Define the character set and viewport settings to ensure multi-language support is adapted to the mobile terminal; 4. Optional tags such as author copyright, robots control and canonical prevent duplicate content should also be configured reasonably.

Best HTML tutorial for beginners in 2025 Best HTML tutorial for beginners in 2025 Jul 08, 2025 am 12:25 AM

TolearnHTMLin2025,chooseatutorialthatbalanceshands-onpracticewithmodernstandardsandintegratesCSSandJavaScriptbasics.1.Prioritizehands-onlearningwithstep-by-stepprojectslikebuildingapersonalprofileorbloglayout.2.EnsureitcoversmodernHTMLelementssuchas,

HTML for email templates tutorial HTML for email templates tutorial Jul 10, 2025 pm 02:01 PM

How to make HTML mail templates with good compatibility? First, you need to build a structure with tables to avoid using div flex or grid layout; secondly, all styles must be inlined and cannot rely on external CSS; then the picture should be added with alt description and use a public URL, and the buttons should be simulated with a table or td with background color; finally, you must test and adjust the details on multiple clients.

How to associate captions with images or media using the html figure and figcaption elements? How to associate captions with images or media using the html figure and figcaption elements? Jul 07, 2025 am 02:30 AM

Using HTML sums allows for intuitive and semantic clarity to add caption text to images or media. 1. Used to wrap independent media content, such as pictures, videos or code blocks; 2. It is placed as its explanatory text, and can be located above or below the media; 3. They not only improve the clarity of the page structure, but also enhance accessibility and SEO effect; 4. When using it, you should pay attention to avoid abuse, and apply to content that needs to be emphasized and accompanied by description, rather than ordinary decorative pictures; 5. The alt attribute that cannot be ignored, which is different from figcaption; 6. The figcaption is flexible and can be placed at the top or bottom of the figure as needed. Using these two tags correctly helps to build semantic and easy to understand web content.

How to handle forms submission in HTML without a server? How to handle forms submission in HTML without a server? Jul 09, 2025 am 01:14 AM

When there is no backend server, HTML form submission can still be processed through front-end technology or third-party services. Specific methods include: 1. Use JavaScript to intercept form submissions to achieve input verification and user feedback, but the data will not be persisted; 2. Use third-party serverless form services such as Formspree to collect data and provide email notification and redirection functions; 3. Use localStorage to store temporary client data, which is suitable for saving user preferences or managing single-page application status, but is not suitable for long-term storage of sensitive information.

What are the most commonly used global attributes in html? What are the most commonly used global attributes in html? Jul 10, 2025 am 10:58 AM

class, id, style, data-, and title are the most commonly used global attributes in HTML. class is used to specify one or more class names to facilitate style setting and JavaScript operations; id provides unique identifiers for elements, suitable for anchor jumps and JavaScript control; style allows for inline styles to be added, suitable for temporary debugging but not recommended for large-scale use; data-properties are used to store custom data, which is convenient for front-end and back-end interaction; title is used to add mouseover prompts, but its style and behavior are limited by the browser. Reasonable selection of these attributes can improve development efficiency and user experience.

Implementing Native Lazy Loading for Images in HTML Implementing Native Lazy Loading for Images in HTML Jul 12, 2025 am 12:48 AM

Native lazy loading is a built-in browser function that enables lazy loading of pictures by adding loading="lazy" attribute to the tag. 1. It does not require JavaScript or third-party libraries, and is used directly in HTML; 2. It is suitable for pictures that are not displayed on the first screen below the page, picture gallery scrolling add-ons and large picture resources; 3. It is not suitable for pictures with first screen or display:none; 4. When using it, a suitable placeholder should be set to avoid layout jitter; 5. It should optimize responsive image loading in combination with srcset and sizes attributes; 6. Compatibility issues need to be considered. Some old browsers do not support it. They can be used through feature detection and combined with JavaScript solutions.

See all articles