I'm having troubles getting a z-index value element with a higher integer to place over another.
This is the issue I am facing.
The bottom half of the register button is being overlapped by the background image.
The code below has been adjusted a bit to only show the code that is being used here. You can see the full site by visiting: https://stangline.com/.
Here is the code:
CSS
.buttonFrame {
margin: 80px auto 50px auto;
display: block;
z-index: 4;
position: relative;
}
.buttonList {
display: inline-block;
vertical-align: top;
}
.homeButton {
font-size: 2rem;
text-decoration: none;
text-transform: uppercase;
letter-spacing: .2rem;
padding: 20px;
cursor: pointer;
box-sizing: border-box;
-webkit-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
position: relative;
z-index: 4;
}
#homeRight {
width: 60%;
height: 100%;
position: absolute;
right: 0;
top: 0;
display: block;
z-index: 2;
}
#homeRightImgFill {
background-position: center center;
background-repeat: no-repeat;
background-size: contain;
width: 95%;
position: relative;
margin: 0 auto;
padding-top: 50%;
z-index: 2;
}
HTML
<div class="buttonFrame">
<a href="/forums" class="homeButton homeButtonGradient buttonList">
Visit Forum
</a>
<a href="/register/" class="homeButton buttonList homeButtonBlue p-navgroup-link--register" data-xf-click="overlay" data-follow-redirects="on">
<span>Register</span>
</a>
</div>
</div>
</div>
</div><div class="homeCont" id="homeRight">
<div id="homeRightImgFill"></div>
</div>
Apply z-index:4 on homeCont class
Related
I am trying to center text in photo. It works in chrome/mozilla perfectly, though there are problems with Safari.
Here are screenshots of the div from different browsers:
Safari:
Chrome:
When page is refreshed on Safari the text is often centered.
I dont have any ideas how to fix that.
HTML:
<div id="giftsHeaderPhoto" class="akcija">
<div class="subCategoryName">
<h1 > Grožis </h1>
</div>
<div class="intro_block">
<div class="intro_text">
<div class="intro_text-short">
<span>{$intro_text}</span>
</div>
<div class="intro_text-buttonBox">
<span class="buttonShowMore">Plačiau</span>
</div>
</div>
</div>
</div>
SCSS:
#giftsHeaderPhoto {
width: 100%;
height: 350px;
background-size: 1920px 350px;
background-position: center top;
background-color: white;
margin-top: 0px;
position: relative;
z-index: 2;
&::after {
content: '';
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.3);
transition: background-color 0.3s;
}
&:hover::after {
background-color: rgba(0,0,0,0.5);
transition: background-color 0.3s;
}
.subCategoryName {
width:80%;
margin: auto;
padding-top: 80px;
padding-bottom: 40px;
color:rgba(white, 0.8);
text-align:center;
position: relative;
z-index: 1;
overflow: hidden;
transition: all 300ms;
letter-spacing: 15px;
h1 {
font-weight: 1000;
color: white;
}
Expected behaviour: subCategoryName class is always centered in any browser.
Outcome: subCategoryName class is more to the right in Safari sometimes.
Try this,
Add the property
margin: auto;
to the container div ie, the parent div where all your sub divisions are contained.
also provide,
text-align: center;
to the actual element to be centered.
if nothing works, a <center>...</center> tag may help.
You can also refer this link for details.
You can use this code
body {
margin: 0px;
}
#giftsHeaderPhoto {
width: 100%;
height: 350px;
background-size: 1920px 350px;
background-position: center top;
background-color: white;
margin-top: 0px;
position: relative;
z-index: 2;
}
#giftsHeaderPhoto::after {
content: '';
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.3);
transition: background-color 0.3s;
}
#giftsHeaderPhoto:hover::after {
background-color: rgba(0, 0, 0, 0.5);
transition: background-color 0.3s;
}
.subCategoryName {
width: 80%;
margin: 0 auto;
padding-top: 80px;
padding-bottom: 40px;
color: rgba(white, 0.8);
text-align: center;
position: relative;
z-index: 1;
overflow: hidden;
transition: all 300ms;
letter-spacing: 15px;
}
h1 {
font-weight: 1000;
color: white;
text-align: center;
}
.intro_block {
text-align: center;
margin: 0 auto;
}
<div id="giftsHeaderPhoto" class="akcija">
<div class="subCategoryName">
<h1> Grožis </h1>
</div>
<div class="intro_block">
<div class="intro_text">
<div class="intro_text-short">
<span>{$intro_text}</span>
</div>
<div class="intro_text-buttonBox">
<span class="buttonShowMore">Plačiau</span>
</div>
</div>
</div>
</div>
I have a button with the text "Description" that in IE is not clickable. Well, actually the far right edge of it is clickable, but not the whole button and text content of the button. It works fine in modern browsers (Chrome, Firefox), but not in IE. I am using IE 11 for testing. What is causing this and how do I fix it?
I've tried to strip out as much as possible...
.vertical-button {
width: 1px;
height: 20px;
background: #000;
position: absolute;
right: -68px;
top: calc(50% - 10px);
display: flex;
flex-direction: column;
justify-content: center;
opacity: 0;
-webkit-transition: 0.8s;
-moz-transition: 0.8s;
-ms-transition: 0.8s;
-o-transition: 0.8s;
transition: 0.8s;
}
.vertical-button {
right: -100px;
}
.project--active .vertical-button {
opacity: 1;
}
.project__image,
.project__text {
position: relative;
width: 100%;
max-width: 408px;
margin: 20px auto;
margin-bottom: 0px;
}
.project__text {
height: 200px;
padding: 8px;
}
.project__image,
.project__text {
width: 280px;
height: 210px;
display: inline-block;
margin: 0 auto;
}
.project__text {
padding-top: 20px;
padding-left: 20px;
}
.project {
-webkit-column-count: 2;
-moz-column-count: 2;
column-count: 2;
padding: 18px;
margin: 30px auto;
width: 614px;
height: 246px;
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.3);
}
.project {
padding: 20px;
width: 740px;
height: 295px;
}
.l-wrapper {
position: relative;
width: 86%;
max-width: 1024px;
margin: 0 auto;
}
.l-wrapper {
width: 80%;
}
.l-clear::after,
.l-wrapper::after {
clear: both;
content: "";
display: block;
height: 0px;
visibility: hidden;
}
.l-section {
padding: 30px 0;
}
.l-section__bg {
background-color: #F2F2F2;
}
.l-container {
position: relative;
padding-bottom: 50px;
overflow: hidden;
background-color: #FFFFFF;
z-index: 99;
}
.vertical-button__btn,
.vertical-button__btn:focus,
.vertical-button__btn:active {
background: none;
border: none;
display: inline;
font: inherit;
margin: 0;
padding: 0;
outline: none;
outline-offset: 0;
position: absolute;
top: 0px;
transform-origin: left top;
transform: rotate(90deg) translateX(-32%);
float: right;
padding: 5px;
cursor: pointer;
cursor: hand;
}
.vertical-button__stroke {
width: 1000px;
height: 1px;
background: #000;
}
<div id="app">
<div data-reactroot="">
<div class="l-container">
<div class="l-section l-section__bg">
<div class="l-wrapper">
<div class="project project--active">
<div class="project__image"></div>
<div class="project__text">
<h3 class="project__heading">Title</h3>
<div class="vertical-button">
<button class="vertical-button__btn">Description</button>
<div class="vertical-button__stroke"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Edit
I have found that if I remove this piece of HTML the button becomes clickable...
<div class="project__image"></div>
But this still doesn't help me understand why it's happening or how to fix it! I cannot actually remove that div in the real project.
I don't have IE to test, but I can tell you some ideas from my experience.
1. Check if another element is overlapping your button.
Being IE, it may handle CSS differently, hence overlapping. Since removing that image class div resolves the problem, I'd guess this would be the cause of the problem.
2. Validate the HTML.
Forgetting to close tags can create very, very bizarre bugs, also difficult to find.
3. Try turning that button into an anchor <a>
There could be browsers who won't handle the click event properly.
4. Stop using IE :)
At least use Edge.
I am having a problem with an element when I use the translate-y in active state, it makes the background-image disappear. Click the element and you will see the image disappear.
The Css:
.glyphsblock i {
display: inline-block;
position: relative;
width: 38px;
height: 38px;
background-size: contain;
background-repeat: no-repeat;
background-position: center, center;
border: 1px solid #fff;
margin: 1px;
flex-shrink: 0;
cursor: pointer;
transition: all ease 0.1s;
}
.glyphsblock i:before {
background: radial-gradient(#8ed3c8, #224945);
content: " ";
width: 100%;
height: 100%;
position: absolute;
z-index: -1;
top: 0;
left: 0;
}
.glyphsblock i:active {
transform: translateY(2px);
}
.glyph-A {
background-image: url(https://atlasdatabase.github.io/glyphs/a.png);
}
HTML Code:
<div class="glyphsblock">
<i class="glyph-A"></i>
</div>
Also a jsfiddle of the issue: https://jsfiddle.net/go0tbb53/
Refactor your CSS to remove the negative z-index, which can produce unpredictable results. This is what was causing the transform to glitch and hide the glyph icon.
I've adjusted your snippet so now the i itself has the radial gradient, and the ::before pseudo-element is laying the glyph graphic on top of it.
You can see it working below:
.glyphsblock i {
background: radial-gradient(#8ed3c8, #224945);
display: inline-block;
position: relative;
width: 38px;
height: 38px;
border: 1px solid #fff;
margin: 1px;
flex-shrink: 0;
cursor: pointer;
transition: all ease 0.1s;
}
.glyphsblock i::before {
background-size: contain;
background-repeat: no-repeat;
background-position: center, center;
content: '';
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
.glyphsblock i:active {
transform: translateY(2px);
}
.glyph-A::before {
background-image: url(https://atlasdatabase.github.io/glyphs/a.png);
}
<div class="glyphsblock">
<i class="glyph-A"></i>
</div>
This may not be totally conventional, but I changed your jsfiddle to use a sized div for the background and an image for the icon itself. If you want to use multiple icons, simply make a larger wrapper div for multiple of what is currently called glyphsblock.
Also, my solution doesn't have any javascript, which is helpful :)
.bg-grad {
background: radial-gradient(#8ed3c8, #224945);
width: 38px;
height: 38px;
z-index: -1;
position: absolute;
}
.glyphsblock:active {
transform: translateY(2px);
cursor: pointer;
transition: all ease 0.1s;
}
<div class="glyphsblock">
<div class="bg-grad">
</div>
<img src="https://atlasdatabase.github.io/glyphs/a.png" height=38px width=38px/>
</div>
I know this question has been asked before (here and here), but for some reason I can't get mine to work when using the same techniques. Basically when you hover over this,
You should get this:
By the way, if there's a simpler way to do this without loading a new image when hovering, please let me know.
Here's what I tried:
HTML
<div class="image">
<a href="#">
<img class="image" src="wp-content/themes/TheBullshitCollection/Images/bs-1.jpg">
</a>
</div>
CSS
.image {
width: 100%;
margin-right: 28px;
margin-bottom: 28px;
display: inline-block;
}
.image a:hover {
display:block;
background-image:url("/wp-content/themes/TheBullshitCollection/Images/bs-1.5.jpg");
margin-right:28px;
margin-bottom:28px;
transition: all 0.2s ease-in-out;
position: absolute;
z-index:1;
width: 100px;
height: 120px;
}
JS Fiddle Link:
https://jsfiddle.net/ot8a5oba/
You can see that the width and height is also confusing me - I'm not sure how to make sure it stays the same size, and that it appears on top. Thanks in advance!
I would do it like this using a pseudo element to apply an overlay. Simplifies things quite a bit.
.imageContainer a {
width: 100%;
display: inline-block;
position: relative;
}
.imageContainer a:after {
position: absolute;
top: 0; left: 0; right: 0; bottom: 0;
background: rgba(139,69,19,0.5);
content: 'Buy';
display: flex;
justify-content: center;
align-items: center;
color: white;
font: 5em cursive;
opacity: 0;
transition: opacity .5s;
}
.imageContainer a:hover:after {
opacity: 1;
}
.imageContainer img {
max-width: 100%;
vertical-align: top;
}
/*
.image a:hover {
display: block;
background-image: url("http://i.imgur.com/ARiA0ua.jpg");
margin-right: 28px;
margin-bottom: 28px;
transition: all 0.2s ease-in-out;
position: absolute;
z-index: 1;
width: 100px;
height: 120px;
}
*/
<div class="imageContainer">
<a href="#">
<img class="image" src="http://i.imgur.com/F2PaGob.jpg">
</a>
</div>
I am creating a site with some nested divs. The navigation bar has been creating an awful horizontal scrollbar. So far I've tried defining the widths of the divs with no luck. I also tried setting a max-width, but that didn't work either.
While I know I could hide the x-overflow, that just seems like a bandaid fix that could cause more problems later on.
Here's a picture of the pesky scrollbar/layout - http://i.imgur.com/i7V3pxf.png
When I inspect element in chrome, it seems that the life_link might be the issue, but I just can't find what's causing it. ):
HTML
<div id='nav'>
<div id='button_wrapper_r'>
<span class='navlink'>characters</span>
<span class='navlink'>guidebook</span>
<span class='navlink'>faq</span>
</div>
<div id='life_link'>LIFE</div>
<div id='button_wrapper_l'>
<span class='navlink'>modbox</span>
<span class='navlink'>packs</span>
<span class='navlink'>members</span>
</div>
</div>
CSS
#nav {
background-image:url("/images/nav_bar.png");
width: 1027px;
height: 151px;
margin-top: 335px;
margin-left: auto;
margin-right: auto;
position: relative;
z-index: 2;
max-width: 1027px;
}
#nav a {
color: #bd916f;
text-transform: uppercase;
letter-spacing: 2px;
font-family: Amaranth;
text-decoration: none;
font-size: 20px;
margin: 20px;
}
#nav a:hover {
color: #eff9ce;
}
#button_wrapper_r {
position: relative;
top: 54px;
left: 26px;
z-index: 3;
}
#button_wrapper_l {
position: relative;
top: -37px;
left: 620px;
z-index: 3;
}
#life_link {
position: relative;
top: 8px;
left: 460px;
z-index: 3;
}
#life_link a {
font-family: 'Cinzel Decorative', cursive;
font-size: 50px;
}
.navlink {
display: inline-block;
vertical-align: middle;
-webkit-transform: translateZ(0);
transform: translateZ(0);
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-moz-osx-font-smoothing: grayscale;
position: relative;
overflow: hidden;
}
.navlink:before {
content: "";
position: absolute;
z-index: -1;
left: 50%;
right: 50%;
bottom: 0;
background: #9bd4bb;
height: 2px;
-webkit-transition-property: left, right;
transition-property: left, right;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
-webkit-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
.navlink:hover:before, .navlink:focus:before, .navlink:active:before {
left: 0;
right: 0;
}
#button_wrapper_l got the same width as your #nav. But then you moving it to the right by position: relative; left: 620px; and get invisible part of that getting through the right side of the #nav element, extending the width of the page.
UPD
I made a JSFiddle using another way to construct your menu – without any relative positions: https://jsfiddle.net/LpbLmmvv/
But there is small problem with width. It doesn't fit your 1027px.
You'd better use flex instead (https://css-tricks.com/snippets/css/a-guide-to-flexbox/). But keep in mind it's browser support – http://caniuse.com/#search=flex