简体   繁体   English

不透明度过渡不起作用,Z索引问题?

[英]Opacity transition not working, z-index issue?

Before I went and reset some of the default properties, everything was working fine, now my opacity effect over each is not working anymore. 在我去重置一些默认属性之前,一切都工作正常,现在我对每个属性的不透明效果不再起作用。 No matter how much I play around with the z-index placement, it doesn't seem to work. 无论我在z-index位置上花多少钱,它似乎都不起作用。

As well, my "like" button isn't positioning correctly in each is not positioning repeatedly in the same location. 同样,我的“喜欢”按钮在每个按钮中的位置都不正确,也没有在相同位置重复放置。

Could someone please look at it for me? 有人可以帮我看看吗? Thank you. 谢谢。

This is the HTML 这是HTML

<!DOCTYPE html> 
<html lang="en"> 

<head> 
<link rel="stylesheet" type="text/css" href="CSS/index.css">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<title>Website Project</title>
<meta charset="utf-8"/> 
</head>
<body>
<header>
    <h1>Vancouver Island University</h1>
    <h1>Health and Wellness Community</h1>
    <h1>"No more excuses"</h1>
    <a href="index.html"><img id="logo" src="Images/VIU-logo-small.jpg" alt="VIU logo" title="VIU logo"></a>
</header>
<img src="Images/websitebackground.jpg" id="background" alt="website background image">
<nav>
    <ul id="menu">
        <li><a href="#">About</a></li>
        <li>
            <input type="checkbox" id="navigation"/>
            <label for="navigation" name="navigation">Events and Workshops</label>
            <ul>
                <li><a href="#">Upcoming Events</a></li>
                <li><a href="#">Upcoming Workshops</a></li>
                <li><a href="#">Request an Event or Workshop</a></li>
            </ul>
        </li>
        <li>
            <input type="checkbox" id="navigation2"/>
            <label for="navigation2" name="navigation2">Resources</label>
            <ul>
                <li><a href="#">Nutrition Resources</a></li>
                <li><a href="#">Physical Activity Resources</a></li>
                <li><a href="#">Mental Health Resources</a></li>
                <li><a href="#">Spiritual Health Resources</a></li>
                <li><a href="#">Social Health Resources</a></li>
                <li><a href="#">Medical Health Resources</a></li>
            </ul>
        </li>
        <li><a href="#">Contact Us</a></li>
        <li><a href="#">Volunteer Opportunities</a></li>
        <li><a href="#">Blog</a></li>
    </ul>
</nav>
<section>
    <div class="sectionalblocks">
        <a target="_self" href="#">
            <img src="Images/blog.png" alt="Blog Article">
            <span class="text-content"><span> Blog </span></span>
        </a><iframe class="likebutton" src="https://www.facebook.com/plugins/like.php?href=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fplugins%2F&width=153&layout=button_count&action=like&size=large&show_faces=true&share=true&height=46&appId" width="153" height="46" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true"></iframe>
    </div>
    <div class="sectionalblocks">
        <div id="articlepreview"><h2>Glorifying Exhaustion: The student crisis</h2><p>It’s that time of year again; between the midterms, papers, and looming final exams, people start to brag about how they are on their sixth extra-large triple-shot coffee, or that they pulled an all-nighter to get their paper in on time...</p></div>
        <a target="_blank" href="http://www.thenav.ca/2016/11/16/glorifying-exhaustion-the-student-crisis/">
            <img id="articleimage" src="Images/articleimage.jpg" alt="Resource Article">
            <span class="text-content"><span>Resources</span></span>

        </a><iframe id="likebutton" src="https://www.facebook.com/plugins/like.php?href=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fplugins%2F&width=153&layout=button_count&action=like&size=large&show_faces=true&share=true&height=46&appId" width="153" height="46" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true"></iframe>
    </div>
    <div class="sectionalblocks">
        <a target="_self" href="#">
            <img src="Images/upcomingevents.png" alt="Upcoming Events Article">
            <span class="text-content"><span>Upcoming Events</span></span>

        </a><iframe class="likebutton" src="https://www.facebook.com/plugins/like.php?href=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fplugins%2F&width=153&layout=button_count&action=like&size=large&show_faces=true&share=true&height=46&appId" width="153" height="46" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true"></iframe>
    </div>
    <div class="sectionalblocks">
        <a target="_self" href="#">
            <img src="Images/volunteer.png" alt="Volunteer Article">
            <span class="text-content"><span>Volunteer</span></span>

        </a><iframe class="likebutton" src="https://www.facebook.com/plugins/like.php?href=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fplugins%2F&width=153&layout=button_count&action=like&size=large&show_faces=true&share=true&height=46&appId" width="153" height="46" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true"></iframe>
    </div>
    <div class="sectionalblocks">
        <a target="_self" href="http://blog.myfitnesspal.com/10-nutritious-smoothies-250-calories/">
            <img src="Images/smoothies.jpg" alt="Nutrition Article">
            <span class="text-content"><span>Nutrition</span></span>

        </a><iframe class="likebutton" src="https://www.facebook.com/plugins/like.php?href=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fplugins%2F&width=153&layout=button_count&action=like&size=large&show_faces=true&share=true&height=46&appId" width="153" height="46" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true"></iframe>
        </div>
    <div class="sectionalblocks">
        <div id="articlepreview"><h2>I Want To Be With Someone Who Knows What It’s Like To Be Broken</h2><p>When seeking a partner, most people have pretty generic things that they’re looking for. They want a man to be handsome, smart, successful, funny, kind. But most qualities that people rattle off don’t go much deeper than that. For me, there’s something rare and unconventional I’m looking for in another person. A quality that I know will mean I truly found the right partner...</p></div>
        <a target="_blank" href="http://thoughtcatalog.com/kelly-bishop/2016/03/i-want-to-be-with-someone-who-knows-what-its-like-to-be-broken/">
            <img id="articleimage" src="Images/mentalhealth.jpg" alt="Mental Health Article">
            <span class="text-content"><span>Resources</span></span>

        </a><iframe id="likebutton" src="https://www.facebook.com/plugins/like.php?href=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fplugins%2F&width=153&layout=button_count&action=like&size=large&show_faces=true&share=true&height=46&appId" width="153" height="46" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true"></iframe>
    </div>
</section>

<aside>
    <ul id="emergencycontact">
        <li>
            <input type="checkbox" id="contact"/>
            <label for="contact" name="contact">Contact</label>
            <ul>
                <h3 class="heading">Emergency Contacts</h3>
                <h4>Assistance Phones</h4>
                <p class="underline"><a href="https://www2.viu.ca/facilities/docs/VIU-AssistancePhones-Map.pdf">Location Map Link</a></p>
                <h4>Vancouver Island University Counselling Services</h4>
                <p class="italic">Monday - Friday; 8 am - 4 pm</p>
                <p>Nanaimo Campus   Phone: 250-740-6416</p>
                <p>Cowichan Campus Phone: 250-746-3509</p>
                <p>Parksville Campus    Phone: 250-248-2096</p>
                <p>Powell River Campus  Phone: (604) 485-2878</p>
                <h4>Mental Health Walk-in Clinic (Crisis Counselling)</h4>
                <p class="italic">Monday - Friday; 10am - 6pm</p>
                <p>Nanaimo  Phone: 250-739-5710</p>
                <p>Location: 203-2000 Island Highway North, Nanaimo, BC V9S 5W3</p>
                <p class="underline"><a href="http://www.viha.ca/mhas/locations/nanaimo/">Island Health Website</a></p>
                <h4>Vancouver Island Crisis Line</h4>
                <p class="italic">7 days a week/24 hours a day</p>
                <p>Phone: 1-888-494-3888</p>
                <p class="underline"><a href="http://www.vicrisis.ca/">Crisis Line Website</a></p>
                <p class="contactheading">Haven Transition House Crisis Line Support for abused women and their children</p>
                <p class="italic">7 days a week/24 hours a day</p>
                <p>Phone: 250-756-0616</p>
                <h4>On Campus Emergency</h4>
                <p class="contactheading">Emergency, First Aid, Security, Ambulance, Fire, Police, Bomb Threat</p>
                <p class="italic">7 days a week/24 hours a day</p>
                <p>Office/Internal Phone Nanaino/Cowichan Phone: 6600</p>
                <p>Office/Internal Phone Powell River   Phone: 8121 or 911</p>
                <p>Office/Internal Phone Parksville Phone: 951-3000 or 911</p>
                <p class="contactheading">Emergency Phone Push button</p>
                <p>Pay Phone Nanaimo    Phone: 740-6600</p>
                <p>Pay Phone Cowichan   Phone: 1-250-740-6600</p>
                <p>Pay Phone Powell River   Phone: 604-485-2878</p>
                <p>Pay Phone Parksville Phone: 951-3000 or 911</p>
                <h4>Off Campus Emergency</h4>
                <p class="contactheading">Police, Fire, and Ambulance Services</p>
                <p class="italic">7 days a week/24 hours a day</p>
                <p>Phone: 911</p>
                <h4>Nanaimo Regional General Hospital</h4>
                <p class="italic">7 days a week/24 hours a day</p>
                <p>Phone: 250-754-2141</p>
                <p>Location: 1200 Dufferin Crescent, Nanaimo, BC V9S 5R6</p>
                <h4>Email contact</h4>
                <p class="underline">behealthy@viu.ca</p>
            </ul>
        </li>
    </ul>
</aside>
<footer id="validator">
    <a href="https://validator.w3.org/nu/?doc=http%3A%2F%2Fmediastudies.viu.ca%2FStudents%2F577081557%2FLabs%2Flab02.html"><img src="Images/html-validator.jpg" alt="HTML validator badge"></a> | <a href="https://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Fmediastudies.viu.ca%2FStudents%2F577081557%2FLabs%2Findex.html&profile=css3&usermedium=all&warning=1&vextwarning=&lang=en"><img src="Images/css-validator.gif" alt="CSS validator badge"></a>
</footer>
</body>
</html>

This is the CSS 这是CSS

 html 
{
    min-width: 100%;
    min-height: 100%    
}

body
{
    margin:0;
    padding:0;
    max-width:100%;
    overflow-y: scroll;
    overflow-x: hidden; /*Disable horizontal scrollbar*/
}

#background /*Background image*/
{
  position: fixed; 
  top: 0; 
  left: 0;  
  /* Preserve aspet ratio */
  min-width: 100%;
  min-height: 100%;
  z-index: -4;
  opacity: .5;
}
*
{
    font-family: 'Roboto', Tahoma, Arial;
}
header
{
    background-color: #144762; /*VIU colours*/
    padding: 30px;
    margin-left: 5px;
    margin-right: 5px;
    margin-top: -10px;
}
#logo
{
    float: left;
    top: 40px;
    left: 40px;
    position: absolute;

}
h1
{
    margin-left: 500px;
    color: #FFFFFF;
}

/*Navigation Menu, <nav>*/
#menu /*entire box*/
{
    list-style: none;
    border: 1px solid #000;
    background-color: #ecffec;/*#444 the Navigator nav color*/
    padding: 0; 
    position: absolute;
    width: 100%;
    left: 0;
    margin: 0;
}
#menu li /*text box*/
{
    margin-right: 3px;
    border: 1px solid #ecffec;
    position: relative;
    list-style: none;
    float: left;
    padding: 0;
    line-height: 15px;
    font-weight: bold;
}
#menu ul /*Actual dropdown menu*/
{
    position: absolute;
    left: 0;
    display: none;
    list-style: none;
    border: 1px solid #000;
    background-color: #ecffec;
    padding: 0;
    margin: 0;
    float: left;
    line-height: 15px;
    width: auto;
}
#menu ul li /*text inside dropdown menu*/
{
    float: none;
    margin: 0;
    padding: 0;
    line-height: 15px;
    min-width: 150px;
}
#menu a:link,
#menu a:visited,
#menu label {
 display: block;
 font-family: 'Roboto', Tahoma;
 font-size: 0.75em;
 font-weight: bold;
 text-align: left;
 text-decoration: none;
 color: #000;
 padding: 5px;
}

#menu li:hover,
#menu input:checked + label {
 background-color: #ffd98a;
 border: 1px solid #000;
}

#menu li:hover ul,
#menu input:checked ~ ul {
 display: block;
}

#menu input {
display: none;
}isited, #menu label { display: block; font-size: 15px; font-weight: bold; text-align: left; text-decoration: none; color: #000; padding: 5px; }

/*Contact information*/
#emergencycontact /*entire box, <aside>*/
{
    list-style: none;
    border: 1px solid #000;
    background-color: #ecffec;
    padding: 0; 
    position: fixed;/*added this*/
    width: 120px;
    right: 0;
    bottom: 0;
    z-index: 5;

}
#emergencycontact li /*text box*/
{
    border: 1px solid #ecffec;
    position: relative;
    float: none;
    margin: 0;
    padding: 0;
    line-height: 15px;
    font-weight: bold;
}
#emergencycontact ul /*Actual popout window*/
{
    position: absolute;
    bottom: 27px;
    right:0;
    width: 500px;
    height: 300px;
    display: none;
    list-style: none;
    border: 1px solid #000;
    background-color: #ecffec;
    padding: 0 0 26px 0;
    margin: 0;
    float: none;
    line-height: 15px;
    overflow: scroll;
    font-weight: normal;
}
#emergencycontact a:link, #emergencycontact a:visited
{
    display: block;
    font-size: 15px;
    font-weight: bold;
    text-align: left;
    text-decoration: none;
    color: #000;
    padding: 5px;
}
#emergencycontact li:hover,
#emergencycontact input:checked + label 
{
  background-color: #ffd98a;
  border: 1px solid #000;
}

#emergencycontact li:hover ul,
#emergencycontact input:checked ~ ul 
{
  display: block;
}

#emergencycontact input 
{
  display: none;
}

#emergencycontact label 
{
  display: block;
  padding: 5px;
}
p.underline
{
    text-decoration: underline;
    margin-left: 20px;
}
p.italic
{
    font-style: italic;
}
.heading
{
    text-align: center;
}
h4{
    text-decoration: underline;
}
p.contactheading{
    font-weight: bold;
}
h4, p.contactheading, p.italic, #emergencycontact p/*text inside dropdown menu*/
{
    float: none;
    margin: 0;
    padding: 15px;
}

/*Sectional blocks*/
section
{
    margin: 40px 23px;
    width: 100%;
}
div.sectionalblocks 
{
    float:left;
    display:inline-block;
    position:relative;
    z-index: -4; 
    width: 400px;
    height: 400px;
}
div.sectionalblocks img /*Image underneath sectional blocks*/
{
    width:400px;
    height:400px;
    display:block;
    float:left;
    position: relative;



}
#articleimage /*Image underneath article*/
{
    position: absolute;
    z-index: -3;
    filter: brightness(80%);
    opacity: 0.8;
}
#articlepreview /*Text inside article sectional blocks*/
{
    position: relative;
    float: left;
    height: 400px;
    width: 360px;
    padding: 20px;
    display: inline-block;
    vertical-align: middle;
    color: white;
}
#articlepreview h2 /*Header text inside article sectional blocks*/
{
    text-decoration: underline;
    color: white;
}
span.text-content /*Text inside sectional blocks*/
{
    float:left;
    position:absolute;
    height:400px;
    width:400px;
    font-family:"proxima nova",sans-serif;
    font-style: normal;
    font-weight: 300;
    font-size: 30px;
    letter-spacing: 4px;
    background: rgba(0,0,0,0.3);
    color: white;
    cursor: pointer;
    display:table;
    opacity:0;
    z-index:5;
    padding:0;
    -webkit-transition: opacity 500ms;
    -moz-transition: opacity 500ms;
    -o-transition: opacity 500ms;
    transition: opacity 500ms;
}
span.text-content span 
{
    display: table-cell;
    text-align: center;
    vertical-align: middle;
}
span.text-content:hover 
{
    opacity:1;
}
iframe.likebutton
{
    position: absolute;
    left: 10px;
    bottom: 0;
    z-index: 5;
}


/*Footer*/
#validator
{
    position: relative;
    bottom:0;
    left: 20px;
    width:100%;

}

Here is the live version: https://jsfiddle.net/nxb8bann/1/ NOTE: The hover opacity transition effect seems to be working here, but not on my browser (chrome/firefox) 这是实时版本: https : //jsfiddle.net/nxb8bann/1/ 注意:悬停不透明度转换效果似乎在这里起作用,但在我的浏览器上不起作用(chrome / firefox)

Your footer section is overlapping your main content. 页脚部分与您的主要内容重叠。 You need to make sure the footer positioning is after the main content where your like buttons are. 您需要确保页脚的位置在您喜欢的按钮所在的主要内容之后。

#validator { clear:both; }

As you say, it seems to work fine in a fiddle so it may be something else in your webpage conflicting. 就像您说的那样,它似乎可以很好地发挥作用,因此可能与您的网页中的其他内容冲突。

as for the position of the 'like' button, you need to change this to absolute position. 至于“赞”按钮的位置,您需要将其更改为绝对位置。 like this. 像这样。

div.sectionalblocks iframe {
    position: absolute;
    left: 15px;
    bottom: 0px;
}

take a look at the amended fiddle here: https://jsfiddle.net/4j5Lkvsc/ 在这里看看修改过的小提琴: https : //jsfiddle.net/4j5Lkvsc/

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

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