如何在移动设备上将现有按钮固定到底部? (引导)

     2023-02-19     81

关键词:

【中文标题】如何在移动设备上将现有按钮固定到底部? (引导)【英文标题】:How to fix an existing button to the bottom on mobile? (bootstrap) 【发布时间】:2022-01-20 20:38:55 【问题描述】:

我在列的容器中有一个现有按钮。我需要将其从桌面上的正常位置更改为固定到移动设备上的屏幕底部。

这是一个例子

#free-offer-button 
  background-color: #d97b6c;
  border-color: #d97b6c;
  border-radius: 0px;
  color: #ffffff;
  font-size: 18px;
  font-weight: bold;
  padding: 9px 23px;
<Col xs= span: 12, order: 2  md= span: 6, order: 1 >
<h3 id='first-container-header'>Treat your pet (and you).</h3>
<h3>It's on us!</h3>
<br></br>

<p>Treat your pet to a healthy treat for <strong>free</strong> to kick off your Public Goods trial membership.</p>
<p><strong>See what it's like to be a Public Goods member.</strong></p>
<ul>
  <li>Included in your bundle is free 2-week membership that gives you unlimited access to our entire collection of sustainable essentials.</li>
  <li>Take a load off. We make it easy for your to make better choices. Always included: eco-friendly products you can trust.</li>
</ul>

<div className='d-grid mt-5'>
  <Button variant="btn-block" id='free-offer-button'> Claim your free offer</Button>
</div>

</Col>

【问题讨论】:

你试过 position absolute 和 bottom: 0 吗? 这能回答你的问题吗? Place button on bottom of div or screen 或者这个***.com/questions/32270496/… 【参考方案1】:

使用媒体查询@media希望您的问题会得到解决。

并且还使用引导类名称class="position-fixed bottom-0"

#free-offer-button
background-color:#d97b6c;
border-color: #d97b6c;
border-radius:0px;
color:#ffffff;
font-size:18px;
font-weight:bold;
padding:9px 23px;

@media only screen and (max-width: 575px) 
  #free-offer-button 
    position:fixed;
    bottom:0;
    font-size:14px;
    width:100%;
    font-weight:normal;
    border:1px solid #d97b6c;
  
<Col xs= span: 12, order: 2  md= span: 6, order: 1 >
                        <h3 id='first-container-header'>Treat your pet (and you).</h3>
                        <h3>It's on us!</h3>
                        <br></br>

                        <p>Treat your pet to a healthy treat  for <strong>free</strong> to kick off your Public Goods trial membership.</p>
                        <p><strong>See what it's like to be a Public Goods member.</strong></p>
                        <ul>
                            <li>Included in your bundle is free 2-week membership that gives you unlimited access to our entire collection of sustainable essentials.</li>
                            <li>Take a load off. We make it easy for your to make better choices. Always included: eco-friendly products you can trust.</li>
                        </ul>

                    <div className='d-grid mt-5'>
                        <Button variant="btn-block" id='free-offer-button'> Claim your free offer</Button>
                    </div>

                </Col>

【讨论】:

谢谢,就是这样,但按钮左侧还有一点空间?由于某种原因,它不是屏幕边缘的全宽【参考方案2】:

使用位置:

<div className='d-grid mt-5 col-12' style="position:'relative'">
<Button variant="btn-block" id='free-offer-button' style="position:'fixed';bottom:0;"> Claim your free offer</Button>
</div>

【讨论】:

固定定位元素总是相对于文档,而不是任何特定的父元素。不需要父级的position: relative

拖动到弹出视图控制器会导致固定到底部的按钮跳转(使用标签栏)

】拖动到弹出视图控制器会导致固定到底部的按钮跳转(使用标签栏)【英文标题】:Draggingtopopviewcontrollercausesbuttonpinnedtobottomtojump(usingatabbar)【发布时间】:2018-02-2108:20:35【问题描述】:我遇到了标签栏控制器的问题。见下图... 查看详情

Android:将按钮文本移动到底部

】Android:将按钮文本移动到底部【英文标题】:Android:MoveButtonTexttobottom【发布时间】:2011-10-1401:38:43【问题描述】:目前我正在创建一个带有图像和文本的按钮。我的问题是我想将文本移动到按钮的底部。<Buttonandroid:layout_weig... 查看详情

如何防止固定到底部的 HTML 元素在 iPhone 上的 WKWebView 中滚动

】如何防止固定到底部的HTML元素在iPhone上的WKWebView中滚动【英文标题】:HowtopreventafixedtobottomHTMLelementfromscrollinginWKWebViewoniPhoneX【发布时间】:2018-08-0216:32:13【问题描述】:我正在使用TurbolinksiOS构建一个混合应用程序,大部分应... 查看详情

iOS 布局约束:当内容到达底部时固定到底部或随内容流动

...一个带有垂直堆栈视图的UIScrollView,它有一个标签和一个按钮,我希望按钮留在屏幕底部,并且一旦标签的文本增加并到达按钮,按钮就会停留在标签下方,它们 查看详情

如何将按钮添加到底部导航视图

】如何将按钮添加到底部导航视图【英文标题】:HowtoaddabuttontoaBottomNavigationView【发布时间】:2021-01-2501:49:49【问题描述】:我想知道如何将按钮添加到BottomNavigationView,我将它包含在BottomNavigationView中。但这是一种解决方法。我... 查看详情

如何在drupal中将javascript移动到底部页脚

】如何在drupal中将javascript移动到底部页脚【英文标题】:howmovejavascripttobottomfooterindrupal【发布时间】:2011-06-2121:55:41【问题描述】:drupal中的性能问题如何将javascript移动到tpl文件的底部页脚??【问题讨论】:【参考方案1】:... 查看详情

如何将标签移动到底部?

】如何将标签移动到底部?【英文标题】:Howtomovethetabstobottom?【发布时间】:2013-02-0819:26:38【问题描述】:我尝试使用TabHost在Android中创建一个带有两个选项卡的选项卡视图。<?xmlversion="1.0"encoding="utf-8"?><LinearLayoutxmlns:andro... 查看详情

仅在滚动到底部时将页脚固定到底部

】仅在滚动到底部时将页脚固定到底部【英文标题】:Fixafootertothebottomonlywhenscrolledtothebottom【发布时间】:2014-12-2418:15:06【问题描述】:我想将页脚固定在浏览器窗口的底部,但仅限于用户已经位于页面底部的情况。如果您在Saf... 查看详情

uiscrollview 不能滚动到底部

...动固定高度,并包含在视图中。在该视图之后有一个分享按钮。除了内容很大时我无法将视图滚动到底部以查看按钮之外,所有构建都正确,因此按钮不在主屏幕之外 查看详情

使用媒体查询在移动设备上隐藏引导工具提示

】使用媒体查询在移动设备上隐藏引导工具提示【英文标题】:HidingBootstrapTooltipsonMobileusingMediaQueries【发布时间】:2012-08-0720:01:53【问题描述】:我在我的网站上的按钮上使用Bootstrap的工具提示,但是当在移动设备上查看时,这... 查看详情

如何在页面底部但在(未固定)页脚上方制作固定的“转到顶部”按钮?

】如何在页面底部但在(未固定)页脚上方制作固定的“转到顶部”按钮?【英文标题】:Howtomakeafixed"gototop"buttononthepagebottom,butabovethe(notfixed)footer?【发布时间】:2018-08-2600:22:30【问题描述】:我已经制作了一个页面(在... 查看详情

SwiftUI 将部分列表固定到底部

】SwiftUI将部分列表固定到底部【英文标题】:SwiftUIpinpartiallisttobottom【发布时间】:2021-05-1901:41:38【问题描述】:我有一个聊天消息列表,随着新消息添加到最后,它会向上滚动。但如果视图中的消息太少,它们会固定在顶部。... 查看详情

如何使用侧边栏将引导导航栏修复到顶部

】如何使用侧边栏将引导导航栏修复到顶部【英文标题】:Howtofixbootstrapnavbartotopwithsidebar【发布时间】:2020-12-0607:45:27【问题描述】:我正在开发一个页面,其中既有sidebar也有navbar我必须将导航栏固定到顶部,以便获得更好的... 查看详情

如何在离子4中单击向下和向上箭头图标按钮垂直离子项目滚动到底部和顶部?

】如何在离子4中单击向下和向上箭头图标按钮垂直离子项目滚动到底部和顶部?【英文标题】:HowtoVerticalion-itemScrolltoBottomandToponDownandUparrowiconbuttonclickinionic4?【发布时间】:2019-10-0819:42:51【问题描述】:我正在创建Ionic4plusAngular... 查看详情

Flutter,如何将 SliverAppbar 上的领先和动作移动到底部

】Flutter,如何将SliverAppbar上的领先和动作移动到底部【英文标题】:Flutter,howtomoveleadingandactiononSliverAppbartothebottom【发布时间】:2021-11-2009:09:22【问题描述】:我正在制作这样的笔记应用:如您所见,我的标题在前导和动作图标... 查看详情

首先引导手机?为啥悬停仍然适用于移动设备?如何禁用悬停?

】首先引导手机?为啥悬停仍然适用于移动设备?如何禁用悬停?【英文标题】:Bootstrapmobilefirst?Whyhoverstillworksonmobile?Howtodisablehover?首先引导手机?为什么悬停仍然适用于移动设备?如何禁用悬停?【发布时间】:2015-06-2221:04:21... 查看详情

如何在禁用按钮上启用引导工具提示?

】如何在禁用按钮上启用引导工具提示?【英文标题】:HowtoenableBootstraptooltipondisabledbutton?【发布时间】:2012-10-2923:30:35【问题描述】:我需要在禁用按钮上显示工具提示并在启用按钮上将其删除。目前,它是反向工作的。扭转... 查看详情

使用动态高度将视图固定到底部

】使用动态高度将视图固定到底部【英文标题】:Pinningaviewtothebottomwithdynamicheight【发布时间】:2016-09-2005:09:56【问题描述】:我有一个UILabel,它可以有可变数量的行数和高度。我想将这个标签固定到我的视图底部,如下所示:... 查看详情