- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
当鼠标光标悬停在按钮上时,文字向下移动,我只需要将文字向左移动5px
,悬停在按钮上时,如何实现?
div {
text-align: center;
}
span {
margin-right: 10px;
}
button {
background: green;
border: none;
padding: 9px;
color: #FFF;
border-radius: 50%;
cursor: pointer;
transition: all 500ms ease;
}
button:hover {
padding: 13px;
transition: all 500ms ease;
}
<div>
<span>test</span><button>⟶</button>
</div>
最佳答案
您面临的“问题”是 span 元素的显示类型是内联的,因此它将跟随其兄弟元素。
我想有多种方法可以解决这个问题。
您可以将 vertical-align: top;
添加到跨度。 ( super 简单的 css 修复,保留 HTML 原样。缺点:将文本修复到元素顶部)
div {
text-align: center;
}
span {
vertical-align: top;
margin-right: 10px;
}
button {
background: green;
border: none;
padding: 9px;
color: #FFF;
border-radius: 50%;
cursor: pointer;
transition: all 500ms ease;
}
button:hover {
padding: 13px;
transition: all 500ms ease;
}
<div>
<span>test</span><button>⟶</button>
</div>
要真正解决这个问题(不让文本流到元素的顶部),您需要在跨度之外添加一个包装元素:
.center {
text-align: center;
}
span {
margin-right: 10px;
}
.wrapper {
display:inline-block;
}
button {
background: green;
border: none;
padding: 9px;
color: #FFF;
border-radius: 50%;
cursor: pointer;
transition: all 500ms ease;
}
button:hover {
padding: 13px;
transition: all 500ms ease;
}
<div class="center">
<p class="wrapper"><span>test</span></p><button>⟶</button>
</div>
您还可以将父级显示为 flex 并相应地调整子级:
.flex {
display: flex;
justify-content: center;
align-items: center;
}
span {
margin-right: 10px;
}
button {
background: green;
border: none;
padding: 9px;
color: #FFF;
border-radius: 50%;
cursor: pointer;
transition: all 500ms ease;
}
button:hover {
padding: 13px;
transition: all 500ms ease;
}
<div class="flex">
<div><span>test</span></div><button>⟶</button>
</div>
关于html - 如何在悬停时将文本向左移动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53979899/
在 Vim 中,是否可以将窗口“移动”到左侧或右侧?例如,类似于 r或 x ,但是左/右而不是上/下? 例如,如果我有这个布局: +---+---+---+ | | +---+ | A +--
我有一系列枚举的网页,目前每个页面上都有一个向左和向右箭头图标,用于导航到该系列中的上一页/下一页。 我的问题:实现向左/向右滑动手势以执行相同操作的最简单(!)方法是什么? (没有其他手势 - 请不
在我的网站上,我有三个 div、一个标题、一个主要内容和右侧的侧边栏。侧边栏是实际问题。我希望侧边栏始终位于浏览器窗口的右侧,如果用户调整窗口大小使宽度低于主栏和侧边栏,则侧边栏会停在主要内容的左边缘
请访问http://lindseymotors.com/v然后单击银色卡车顶部的照片。当展开的 View 弹出时,主照片下方有一排照片。当您点击它们时,它会切换到该照片并在您选择的图像上方显示“正在查
请看一下这个 DEMO 。 使用 this post 中的代码我已成功通过单击左侧或右侧链接使图像水平移动。 我想要实现的是以某种方式使图像跳跃更平滑。 这是我的代码: var scroll
我正在尝试向子菜单添加一个不错的小效果,但我不能使用 marginLeft,因为它会弄乱容器。所以我试图通过使用 left 而不是 marginLeft 来实现它,但我无法让它工作......任何想法
我有一个日历,我想让左右滑动和切换月份成为可能。 是否有任何听众向左/向右滑动? 谢谢! 最佳答案 您可以像下面的示例一样使用 SimpleOnGestureListener:(显然,将 toast
我正在尝试实现一个ng-repeats 水平用户媒体对象的小部件,我应该能够向左/向右滑动以显示下一张媒体卡。小部件应该看起来像这样 如图所示 下一张卡片头像是半可见的,暗示还有更多卡片可以刷。 这就
我正在创建一个显示多个“页面”内容的应用程序。通常,这代表基于桌面的应用程序上的选项卡。 在 android 上,我希望能够在屏幕上的任意位置使用手指在信息选项卡之间轻拂。这些选项卡的内容将只是 XM
我正在使用: ViewController = [[ViewControllerClass alloc] initWithNibName:@"ViewControllerClass" bundle:[
这个问题已经存在: How to make this into a sliding left/right div 已关闭10 年前。 下面提供的是我的 html 和 css 代码的片段,我不仅需要在
尝试将 h3 向左滑动,p 向右滑动,.info 从下到上滑动 slider .实际上它在没有 jQuery 的 Chrome 和 Opera 中工作得很好,因为我使用了 Animate.css,但它
我发现这个很好的进度条 CSS 动画。 但我想transform: translate而不是left/right。 如何切换到 transform 它?我试过了,但它不起作用: https://cod
我想用 bootstrap 创建一个表,并在列中插入一些左拉和右拉的内容: http://jsfiddle.net/Zoker/sgdfgkvL/ Some content Some
我怎样才能得到 重叠并停在 Logo 的左边缘?当屏幕宽度扩展时,我试图让绿色条向左扩展,但我希望它停在 Logo 的左边缘。 我试过了 position: absolute;在 #green_bar
试图将这个“手势”功能添加到我的第一个程序中,几乎我所做的每一次搜索都来到了这个线程: Fling gesture detection on grid layout 我能够让它工作..但就我而言,我不
我有带 tablayout 的 viewpager,在 ViewPager 内部我有一个正在创建 RecyclerView 的 fragment , 在 RecyclerVIew roe 项目中,我创
我一直在研究图片库 [html5],它在桌面版本中运行良好,我想为 Ipad/平板电脑设备添加基于触摸的事件。 您能否建议如何使用 javascript/jquery 添加基于触摸的事件。 谢谢,斯里
所以我想通过将盒子相乘然后去掉下半部分来使盒子向各个方向移动。向上和向右有效,但向下和向左无效。单击 4 个按钮中的 1 个即可调用这些功能。基本的 CSS 和 HTML。我该如何解决这个问题? va
我已经像这样创建了一个 RecyclerView ItemTouchHelper - public class MyItemTouchHelper extends android.support.v7
我是一名优秀的程序员,十分优秀!