您的位置:

CSS Down and to the Left

一、简介

CSS Down and to the Left是一个CSS技巧,使用此技巧可以实现元素向下和向左的渐进式偏移。通常,这个技巧是用于实现特殊的设计效果,比如dialog box,popover等。

二、CSS Down and to the Left的实现

首先,CSS Down and to the Left的实现需要三个步骤,如下:

  1. 为元素设置 “position: relative;”
  2. 为元素设置“left: -25px; top: 25px”
  3. 为元素设置 “margin: -10px 0 0 -10px”
    <style>
        .box {
            position: relative;
            left: -25px;
            top: 25px;
            margin: -10px 0 0 -10px;
        }
    </style>
    
    <div class="box"></div>

这样,元素就可以向下和向左渐进式偏移。同时,为了使这个特效更加集中体现在元素的边框之内,我们可以为元素添加一个“overflow:hidden”的属性,如下:

    <style>
        .box {
            position: relative;
            left: -25px;
            top: 25px;
            margin: -10px 0 0 -10px;
            overflow: hidden;
        }
    </style>
    
    <div class="box"></div>

三、CSS Down and to the Left的应用

CSS Down and to the Left可以用于优化popover的效果。我们可以为popover添加一个透明度的渐进式动画,同时让它向下和向左飞出。下面是实现代码:

    <style>
        .popover {
            position: absolute;
            left: 0;
            top: 0;
            opacity: 0;
            transform: translate(-25px, -25px);
            transition: opacity 0.15s ease-out, transform 0.15s ease-out;
        }

        .popover.animate {
            opacity: 1;
            transform: translate(0, 0);
        }
    </style>
    
    <div class="popover animate">
        <p>这是一个popover。</p>
    </div>
    
    <script>
        document.querySelector('.popover').classList.add('animate');
    </script>

通过给元素添加“position: absolute;”属性,实现popover的定位。然后,首先将元素的透明度设置为0,同时通过设置“transform: translate(-25px, -25px);”来让它向下和向左偏移。最后,通过添加一个类名“animate”,通过设置元素的透明度和位置属性来触发渐进式动画。

四、总结

CSS Down and to the Left是一个常用的CSS技巧,可以实现元素向下和向左的渐进式偏移。在popover等特殊效果下,可以通过这个技巧优化页面的效果。同时,在使用这个技巧的时候,需要注意设置元素的“position”属性和“margin”属性,以及设置元素的透明度和位置属性来触发渐进式动画。

CSS Down and to the Left

2023-05-12
CSS Box to the Left

2023-05-12
时钟的css和js,css做时钟

本文目录一览: 1、求css动态时钟以及日历的代码(运行能用的,没用的不要写上来了,谢谢)(与电脑时间同步) 2、怎样用html和css做时钟的转动效果 3、如何用jQuery和CSS3制作数字时钟

2023-12-08
CSS Point Size to Inches Conve

2023-05-12
CSS边框笔记

2023-05-12
CSS语速

2023-05-12
php点点滴滴,PHP笔记

2022-11-20
CSS垂直动画:向上和向下运动的元素

2023-05-12
CSS Image Align Left

2023-05-12
when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: ${item.id} [in template "article/detail/index.ftl" at line 48, column 106] ---- Java stack trace (for programmers): ---- freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...] at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:134) at freemarker.core.EvalUtil.coerceModelToTextualCommon(EvalUtil.java:481) at freemarker.core.EvalUtil.coerceModelToStringOrMarkup(EvalUtil.java:401) at freemarker.core.EvalUtil.coerceModelToStringOrMarkup(EvalUtil.java:370) at freemarker.core.DollarVariable.calculateInterpolatedStringOrMarkup(DollarVariable.java:104) at freemarker.core.DollarVariable.accept(DollarVariable.java:63) at freemarker.core.Environment.visit(Environment.java:371) at freemarker.core.IteratorBlock$IterationContext.executedNestedContentForCollOrSeqListing(IteratorBlock.java:321) at freemarker.core.IteratorBlock$IterationContext.executeNestedContent(IteratorBlock.java:271) at freemarker.core.IteratorBlock$IterationContext.accept(IteratorBlock.java:244) at freemarker.core.Environment.visitIteratorBlock(Environment.java:645) at freemarker.core.IteratorBlock.acceptWithResult(IteratorBlock.java:108) at freemarker.core.IteratorBlock.accept(IteratorBlock.java:94) at freemarker.core.Environment.visit(Environment.java:335) at freemarker.core.Environment.visit(Environment.java:341) at freemarker.core.Environment.visit(Environment.java:341) at freemarker.core.Environment.process(Environment.java:314) at freemarker.template.Template.process(Template.java:383) at org.springframework.web.servlet.view.freemarker.FreeMarkerView.processTemplate(FreeMarkerView.java:332) at org.springframework.web.servlet.view.freemarker.FreeMarkerView.doRender(FreeMarkerView.java:266) at org.springframework.web.servlet.view.freemarker.FreeMarkerView.renderMergedTemplateModel(FreeMarkerView.java:220) at org.springframework.web.servlet.view.AbstractTemplateView.renderMergedOutputModel(AbstractTemplateView.java:181) at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:314) at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1431) at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1167) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1106) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:979) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:903) at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:564) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:885) at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:205) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) at com.software.filter.HttpSpiderIdentifyFilter.doFilter(HttpSpiderIdentifyFilter.java:51) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:340) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:391) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:896) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1744) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52) at java.base/java.lang.VirtualThread.run(VirtualThread.java:309)