首页 \ 问答 \ 使用链接使整个div可点击(making entire div clickable with a link)

使用链接使整个div可点击(making entire div clickable with a link)

在我提出这个问题之前,我先说一下。我确实尝试了很长时间通过现有主题,但我找不到解决问题的方法。

我正在使用Bootstrap并且有一个水平的项目列表,其中包含图标和下面的文本链接。 我想要的基本上是整个div可点击作为链接,而不仅仅是实际的文本。

这是HTML:

<ul class="glyphs character-mapping">
                <li>
                  <div data-icon="a" class="icon"></div>
                  <a href="">Link 1</a>
                </li>
                <li>
                  <div data-icon="b" class="icon"></div>
                  <a href="">Link 2</a>
                </li>
</ul>

而CSS:

.glyphs.character-mapping {

margin: 0px;
padding: 0px;
color: #000000;

}
.glyphs.character-mapping li {

margin: 0px 10px 30px;
display: inline-block;
width: 165px;
text-align: center;

}
.glyphs.character-mapping .icon {

margin: 10px 0px 10px 45px;
padding: 0px;
position: relative;
width: 70px;
height: 70px;
color: #FF0000;
overflow: hidden;
border-radius: 3px;
font-size: 68px; 

}

我尝试了几个与此相关的解决方案,包括不给“li”填充或填充,而是将'a'设为100%宽和高,但这也不起作用。

我在这里做错了什么想法?

非常感谢你提前帮忙。


Let me just say before I ask this question ..I did try searching for a long time through existing topics but I can't find a working solution to my problem.

I am using Bootstrap and have a horizontal list of items with icons and a text link underneath. What I want is basically the entire div clickable as the link, not just the actual text.

Here is the HTML:

<ul class="glyphs character-mapping">
                <li>
                  <div data-icon="a" class="icon"></div>
                  <a href="">Link 1</a>
                </li>
                <li>
                  <div data-icon="b" class="icon"></div>
                  <a href="">Link 2</a>
                </li>
</ul>

And the CSS:

.glyphs.character-mapping {

margin: 0px;
padding: 0px;
color: #000000;

}
.glyphs.character-mapping li {

margin: 0px 10px 30px;
display: inline-block;
width: 165px;
text-align: center;

}
.glyphs.character-mapping .icon {

margin: 10px 0px 10px 45px;
padding: 0px;
position: relative;
width: 70px;
height: 70px;
color: #FF0000;
overflow: hidden;
border-radius: 3px;
font-size: 68px; 

}

I tried several solutions that are related on here, including giving no padding or margin to the 'li' and instead making the 'a' 100% wide and high, but that didn't work either.

Any ideas what I'm doing wrong here?

Thank you so much in advance for any help.


原文:
更新时间:2022-04-21 15:04

最满意答案

你的旅费可能会改变。 一些网页生成工具支持RTL轻松切换,而与其他网页生成工具一样,当您指定<html dir="rtl">时,WYSIWYG会完全中断。 浏览器碎片也可能是一个问题:某些浏览器根本不支持正确的RTL项目符号列表。

网上有很多很好的教程; 我建议https://hacks.mozilla.org/2015/09/building-rtl-aware-web-apps-and-websites-part-1/https://hacks.mozilla.org/2015/10/ building-rtl-aware-web-apps-websites-part-2 / 。 如果你查找谷歌搜索更多文章,请记住这个领域正在迅速改变,几年前的一些食谱可能已经过时。

您可能会发现css-fliprtlcss的自动化非常有用。

请注意,本地化通常并不容易,并且总是需要手动触摸。 您必须非常了解目标文化,以识别可能对最终用户来说可怕的微小故障。 例如,在希伯来语网站上,“后退”按钮需要不同的图像。 在阿拉伯语网站上,一些数字应该用指示数字表示,但其他数字应该使用通常的数字。

LTR本地化也常见一周的第一天等问题。


Your mileage may vary. Some web page generation tools support RTL with easy switch, while with others the WYSIWYG breaks completely when you specify <html dir="rtl">. Browser fragmentation may also be an issue: some browser simply don't support RTL bulleted lists correctly.

There are quite a few good tutorials on the Web; I would recommend https://hacks.mozilla.org/2015/09/building-rtl-aware-web-apps-and-websites-part-1/ and https://hacks.mozilla.org/2015/10/building-rtl-aware-web-apps-websites-part-2/. If you look up Google to search for more articles, please remember that this field is quickly changing, and some recipes of few years ago may be obsolete.

You may find the automation with css-flip or rtlcss useful.

Note that localization is generally not easy, and invariably requires a manual touch. You must understand the target culture very well to recognize tiny glitches that may look awful to the end-user. For example, on Hebrew Website you need different image for the "back" button. On Arabic sites, some numbers should be represented by indic digits, but other numbers are expected to use the usual digits.

Issues of first day of week, etc. are common for LTR localizations, too.

相关问答

更多
  • 使用浏览器对占位符的特定伪调用应该排除您的问题 input[type="text"]:-moz-placeholder { text-align: right; } input[type="text"]:-ms-input-placeholder { text-align: right; } input[type="text"]::-webkit-input-placeholder { text-align: right; } .input{ direction: rtl; } ...
  • 我没有找到任何记录的方法来执行此操作,但将属性bidiLaouytOrientation设置为ltr或rtl在2.6.1中适用于我: 创建报告参数,例如useRTL of boolean type。 然后在beforeFactory报告脚本中设置参数: var designHandle = reportContext.getReportRunnable().designHandle; if (params['useRTL'].value == true) designHandle.setProper ...
  • 我发现最接近的东西,我把一个方法放在acontroller中获取lang()然后得到它的RTL或LTR然后加载CSSs和JSs来自我的main.scala.html。 所以我不应该担心从每个控制器方法传递if语句,main,scala.html中的代码将是这样的: @if(Language.isRTL()){
  • 一开始,我认为这是一个bug(与unicode-bidi: bidi-override相关的东西unicode-bidi: bidi-override ),但是当我尝试使用IE,Edge和Firefox时,他们都给出了相同的结果。 这给了我足够的证据证明这是一种正常行为。 我到处看看,发现了什么是错的。
  • 解决方案是创建2个资产文件,一个用于设计者设计的页面,另一个用于由gii生成的页面 The solution was to create 2 asset files, one for the pages designed by the designer, and the other for pages generated by gii
  • 在Windows下,您可以通过UniScribe API执行此操作。 我使用它将Unicode文本转换为字形集,用于我们的开源PDF编写器 。 您在SynPdf.pas单元中有源代码示例。 请参阅TPdfWrite.AddUnicodeHexTextUniScribe方法: function TPdfWrite.AddUnicodeHexTextUniScribe(PW: PWideChar; WinAnsiTTF: TPdfFontTrueType; NextLine: boolean; Canvas ...
  • 似乎算法基于文本的第一个基于字母的字符决定(即它找到非符号字符并检查它是否是RTL字符)。 您可以在RegEx中使用\p{L}或\p{Letter}来查找第一个匹配项,然后将其第一个字符与RTL unicode字符的范围进行比较: boolean isRtl(String str) { Pattern p = Pattern.compile("([^\\p{L}]*)(\\p{L})(.*)"; Matcher m = p.matcher(str); if (m.matches()) ...
  • 根据我们在主帖中讨论的评论,您可以使用属性选择器进行定位并交换文本方向: [dir="rtl"] .textCongregation{ text-align: right; } [dir="rtl"] .textTitle { text-align: left; } 详细了解属性选择器: https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors According with the comments we are talkin ...
  • 你的旅费可能会改变。 一些网页生成工具支持RTL轻松切换,而与其他网页生成工具一样,当您指定时,WYSIWYG会完全中断。 浏览器碎片也可能是一个问题:某些浏览器根本不支持正确的RTL项目符号列表。 网上有很多很好的教程; 我建议https://hacks.mozilla.org/2015/09/building-rtl-aware-web-apps-and-websites-part-1/和https://hacks.mozilla.org/2015/10/ buildin ...
  • 使用sass mixins处理它 优点: 与方法#2相比,输出文件更小 由于使用了rtl和ltr mixins,你将拥有语义sass 缺点: 您不能在单个输出文件中同时支持rtl和ltr 使用html标签的dir attr处理它 优点: 您不需要编译两次sass文件(您可以在单个文件中支持rtl和ltr ) 缺点: 由于长css规则,您的输出文件可能会变得很重 使用sass vars处理它 优点: 与方法#2相比,输出文件更小 与方法#1相比,较小的sass文件 缺点: 您不能在单个输出文件中同时支持rtl ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)