简体   繁体   English

<a href=“ window.open (…) ”>不工作</a>

[英]<a href=“ window.open (…) ”> not working

I have two pieces of text, one alligned right and one aligned left. 我有两段文字,一是右对齐,另一是左对齐。 The text on the right works fine and links to the correct pages, however, the links on the left do not work. 右边的文本可以正常工作,并且可以链接到正确的页面,但是,左边的链接不起作用。 They don't even appear as links. 它们甚至不显示为链接。 The site is live here - http://kingdombrand.com/Film/Films/TestFilm (ps. It can only be accessed via the link and can't be found on the site navigation) 该网站位于此处-http://kingdombrand.com/Film/Films/TestFilm (ps。只能通过链接进行访问,而无法在网站导航上找到)

Here is the code used 这是使用的代码

<div class="VideoText" align="left">
    <a href=""><span> <strong> Credits </strong> </span></a> <br>                    
    Directed By: <a href="http://www.kingdombrand.com/Film/Alek/Portfolio"> Link One </a> <br>
    Edited By:   <a href="http://www.kingdombrand.com/Film/Jess/Portfolio"> Link Two </a>
    <br>                                 
    <br>                           
</div>

<!-- S H A R E-->
<div class="VideoShare" align="right">
    <b> Share </b> <br>
    <a href="http://www.twitter.com/share">Twitter</a><br>
    <a href="#" onclick=" window.open(
      'https://www.facebook.com/sharer/sharer.php?u='+encodeURIComponent(location.href), 
      'facebook-share-dialog', 
      'width=626,height=436'); 
       return false;">
       Facebook
    </a>
    <br>
</div>

And here is the CSS: 这是CSS:

.VideoText {
   position: absolute;
    left: 200px;
    top:  475px;
    overflow:visible
}

.VideoShare {
   position: absolute;
    Left: 200px;
    width:67.5%;
    top:  475px;
    overflow:visible;
}

The links do work, they're only covered by your div.VideoShare . 链接确实有效,它们仅在div.VideoShare覆盖。 Put a display: none; display: none; on the latter and hover over the links to check them. 在后者上,将鼠标悬停在链接上以进行检查。

I can't help you with a solid CSS solution. 我无法为您提供可靠的CSS解决方案。 Personally I'd float: right (or display: inline-block ) the video share buttons, so their containing div doesn't stretch 100% horizontally. 就我个人而言,我会float: right (或display: inline-block )视频共享按钮,因此其包含的div不会水平拉伸100%。 There may be better solutions though. 不过,可能会有更好的解决方案。

Seems to be a z-index issue, just add a z-index for both: 似乎是z-index问题,只需为两者都添加z-index:

.VideoText {
    position: absolute;
    left: 200px;
    top:  475px;
    overflow:visible;
    z-index: 2;
}

.VideoShare {
    position: absolute;
    Left: 200px;
    width:67.5%;
    top:  475px;
    overflow:visible;
    z-index: 1;
}

From MDN : MDN

The z-index property specifies the z-order of an element and its descendants. z-index属性指定元素及其后代的z顺序。 When elements overlap, z-order determines which one covers the other. 当元素重叠时,z顺序确定哪个覆盖另一个。 An element with a larger z-index generally covers an element with a lower one. 具有较大z索引的元素通常会覆盖具有较低z索引的元素。

Try this 尝试这个

.VideoText {
   position: absolute;
    left: 100px;
    top:  475px;
    overflow:visible
}

.VideoShare {
   position: absolute;
    Left: 300px;
    width:67.5%;
    top:  475px;
    overflow:visible
}

Put z-index: 1; 放入z-index: 1; to

.VideoText {
}

Your .VideoShare div cover your links. 您的.VideoShare div包含您的链接。 Try to remove width and position your div with right instead of left. 尝试删除宽度,然后将div的位置改为右侧而不是左侧。 Because you need it to be on right. 因为您需要它正确。

.VideoShare {
  ...
  /* left: 200px; */
  right: 200px;
  /* width: 67.5%; */
  ...
}

Solution is quite simple )) Link at the left are correct but covered by your div with class="VideoShare". 解决方案非常简单))左侧的链接正确无误,但您的div覆盖了class =“ VideoShare”。 You may try to correct left:200px to left:400px for example for class="VideoShare" and hope you will get what i mean 您可以尝试将left:200px校正为left:400px,例如class =“ VideoShare”,希望您能明白我的意思

Your two containers are just overlapping each other, as I said in my comment above. 正如我在上面的评论中所说,您的两个容器彼此重叠。 You could make both containers the same width and move the right container to the right side with the absolute positioning. 您可以使两个容器具有相同的宽度,并通过绝对定位将右侧的容器移至右侧。

.VideoShare {
    left: auto;
    top: 475px;
    width: 200px;
    right: 200px;
    position: absolute;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM