- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在使用 CSS 为网络应用程序创建工具提示。到目前为止,我有一个非常方便的工具提示与以下类一起使用:
两者的区别在于箭头和动画。例如,“tooltip-right”类有一个指向左侧的箭头,它从左到右动画。
当工具提示有很多文本时,问题就来了,当工具提示中有很多文本时,tooltip-left、-right 和-up 的位置都不同。向下工具提示没有问题,因为默认情况下一切都向下环绕。
所以我的问题是,是否可以仅使用 CSS 来完美定位工具提示。或者会涉及一些 JS,如果是这样,你建议做什么?也许添加检查以查看工具提示有多少文本并添加一些内联 css 作为边距?例如,我试图复制 http://foundation.zurb.com/sites/docs/v/5.5.3/components/tooltips.html ,我们正在使用基础,但它和 Angular 似乎存在一些问题。
这是我到目前为止的一些代码:
.tooltip-up,
.tooltip-down,
.tooltip-left,
.tooltip-right {
font-size: 12px;
position: absolute;
text-align: center!important;
visibility: hidden;
background-color: rgba($gray, 0.99);
color: #fff;
text-align: left;
border-radius: 3px;
width: 250px;
height: auto;
padding: 7px 10px;
z-index: 1;
opacity: 0;
box-shadow: 0 2px 5px 0 rgba($solid-black, 0.16), 0 2px 10px 0 rgba($solid-black, 0.12);
@include transition (.2s ease-in);
}
.tooltip-right {
top: -35%;
left: 135%;
transform: translateX(-15%);
margin-top: -10px;
&:after {
border-right: 7px solid rgba($gray, 0.99);
border-bottom: 7px solid transparent;
border-top: 7px solid transparent;
top: 50%;
content: " ";
height: 0;
left: -7px;
position: absolute;
width: 0;
transform: translateY(-50%);
}
}
请记住,有四个工具提示类,因此您的解决方案必须同时考虑左侧、右侧和顶部的工具提示。感谢您事先提供的任何信息和帮助。 p>
最佳答案
您可以使用与定位箭头相同的技巧:将 translateY(-50%)
与 position: absolute
和 结合使用顶部:50%
。
因为 50%
是相对于工具提示的,所以它总是居中。两个陷阱:
p { display: inline-block; position: relative; border: 1px solid red; }
.tooltip-right {
box-sizing: border-box;
font-size: 12px;
position: absolute;
text-align: center;
background-color: black;
color: #fff;
text-align: left;
border-radius: 3px;
width: 250px;
padding: 7px 10px;
z-index: 1;
opacity: .8;
top: 50%;
right: 0;
/* width + arrow width = 250 + 7 = 257 */
transform: translate3d(257px, -50%, 0);
}
.tooltip-right::after {
content: "";
border-right: 7px solid black;
border-bottom: 7px solid transparent;
border-top: 7px solid transparent;
position: absolute;
height: 0;
width: 0;
left: -7px;
top: 50%;
transform: translateY(-50%);
}
<h2>Use translateY for positioning</h2>
<p>
<span>
Lorem ipsum
</span>
<span class="tooltip-right">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</span>
</p>
关于javascript - 使用 CSS 或 JS 定位工具提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41430061/
我的 friend 编写了一个程序,它比较随机排列的骰子面,以找到分布最均匀的面——尤其是当面不仅仅是序列时。 我将他的程序翻译成 haskell 是因为我一直在寻找一个理由来让别人知道 haskel
我需要对表单中的某些字段进行评论/提示。我的想法是在模型中描述它,就像attributeLabels一样。我该怎么做? 然后它会是理想的,如果 Gii 模型(和 Crud)生成器直接从 mysql 列
我们使用 FastReport 来生成报告。事实上,我们为访问源代码付费。 我们目前使用的是 FastReport 的最新稳定版本。虽然它对于我们的生产来说足够稳定,但每当我编译时,我都会看到以下内容
我需要创建一个对话框/提示,包括用于用户输入的文本框。我的问题是,确认对话框后如何获取文本?通常我会为此创建一个类,将文本保存在属性中。不过我想使用 XAML 设计对话框。因此,我必须以某种方式扩展
我想提示用户是否要执行操作(删除) - 用警报框说"is"或“否”,如果是,则运行删除脚本,如果否,则不执行任何操作 我不太了解 javascript,因此是否有人可以使用 javascript 获得
所以我正在编写一个简单的 JS 代码。我们刚刚开始学习函数。我需要创建一个名为“printStars”的函数。 我需要从用户那里获取一个号码,并根据该号码打印“*”。 这就是我所做的:
我在我的页面上添加了一个提示,但它在页面加载之前加载了。如何仅在整个页面可见时才显示消息? 这是我的提示: if (name == null || name == "") { txt == "No
我在我的页面上添加了一个提示,但它在页面加载之前加载了。如何仅在整个页面可见时才显示消息? 这是我的提示: if (name == null || name == "") { txt == "No
我正在自定义我的 zsh 提示,并发现以下内容来检查是否有任何后台作业: if [[ $(jobs | wc -l) -gt 0 ]]; then # has background job(s)
这个问题在这里已经有了答案: JavaScript object: access variable property by name as string [duplicate] (3 个答案) pa
我正在尝试用 javascript 制作一个简单的数学练习程序。在提示警报中给出不同的值,并将答案与用户输入进行比较。这是代码: Calculations generate(); functio
在这段代码中,尽管我使用了文本对齐属性在“编辑文本” View 的中心设置“提示”。但它无法正常工作。 最佳答案 尝试 关于android - 如何在编辑文本的中心对齐文本(提示),我们在Sta
我正在尝试让我的 EditText 显示一个提示,例如“请在此处输入答案”,当用户点击 EditText 以键入他们的答案时,文本应该消失并留空,以便他们在其中输入答案. 截至目前,这就是我的 .xm
我当前的 android 应用程序中有两个微调器,我想要一个默认值,例如 editText 的 android:hint 功能。有没有办法这样做,但不会将提示添加到填充微调器的字符串数组。例如从微调器
如果我的表单已完全填写,我如何提示“感谢您填写表单,“name”!” function submit_onclick() { if(confirm("Thanks for completing t
我刚刚了解了prompt()命令;我知道 Prompt() 命令以字符串的形式返回用户输入。我正在搞乱下面的程序,我输入了Per“Dead”Ohlin作为男性名字。为什么这有效并且没有引起任何问题?
void openUpNow(FILE *x, FILE *y) { x = fopen("xwhatever", "r"); y = fopen("ywhatever", "r");
我有一个作业正在处理,但我在使用 prompt() 方法时遇到了问题。我看到我可以做一个提示,但我需要几个并且有数量。 例如... 我创建了一个 HTML 表格,其中包含许多艺术家和包含 DVD、CD
我正在学习 Big Nerd Ranch 的 iOS Programming, 2nd Edition,我已经来到第 4 章挑战:标题。该练习暗示我感到困惑;它说我需要做一些我认为不需要做的事情。 到
抱歉,如果这是微不足道的,但我没有找到任何解决此问题的建议。我在 Ubuntu 上,我的 Yii 项目需要 PHPUnit。我已经安装了 PHPUnit 两次,方法是下载 phpunit.phar 并
我是一名优秀的程序员,十分优秀!