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>
Related
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
I am trying to implement button I took from codepen on my existing "box-list" div.
But in my form the button gets fathers background and I cant perform my original button blue background as it should be.
On the bottom of the page you can see the button outside the "box-list" how it should look.
<link rel="stylesheet" type="text/css" href="style.css">
<div class="box-list">
<!-- FREE TEXT BOX -->
<div class="box" >
<div class="box__inner">
<h1>Free Text</h1>
Get you free text processed and analyzed, and get opinion summery about.
<button class="analyzeBtn mybtn1" >hover</button>
</div>
</div>
<!-- TWITTER BOX -->
<div class="box" >
<div class="box__inner">
<h1>Twitter Search</h1>
Get Twitter post and comments about any subject you choose and analyze the dat
</div>
</div>
<div class="box" >
<div class="box__inner">
<h1>URL</h1>
Get your URL article analyzed
</div>
</div>
</div>
<button class="analyzeBtn mybtn1" >hover</button>
.box-list {
background: #119bc9;
overflow: hidden;
display: flex;
}
.box {
min-height: 300px;
color: #fff;
transition: all 0.5s;
max-height: 300px;
background-image: url('http://lorempixel.com/400/300/sports');
background-size: cover;
width: 33.33%;
}
.box__inner {
padding: 20px;
min-height: 300px;
background-color: rgba(17, 155, 201, 0.7);
}
.box:hover {
width: 150%!important;
font-size: 18px;
}
.box:nth-child(odd) {
background-image: url('/images/text.jpg');
}
.box:nth-child(odd) .box__inner{
background: rgba(71, 83, 157, 0.8);
}
.analyzeBtn {
border: 1px solid #3498db;
background: none;
padding: 10px 20px;
font-size: 20px;
font-family: "montserrat";
margin: 10px;
transition: 0.8s;
position: relative;
cursor: pointer;
overflow: hidden;
border-radius: 5px;
}
.mybtn1 {
color: #fff;
}
.mybtn1:hover {
color: #3498db;
transform: translateY(-7px);
transition: 0.4s;
}
.analyzeBtn::before {
content: "";
position: absolute;
left: 0;
width: 100%;
height: 0%;
background: #3498db;
z-index: -1;
transition: 0.6s;
}
.mybtn1::before {
top:0;
border-radius: 0 0 50% 50%;
height: 180%;
}
.mybtn1:hover::before {
height: 0%;
}
JSfiddle example
You need to add z-index: 1; to the button so that it is displayed on top of the backgrounds:
.analyzeBtn {
border: 1px solid #3498db;
background: none;
padding: 10px 20px;
font-size: 20px;
font-family: "montserrat";
margin: 10px;
transition: 0.8s;
position: relative;
cursor: pointer;
overflow: hidden;
border-radius: 5px;
z-index: 1;
}
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 trying to get it so that the user can submit comments on the "back" of an element that does a 3d flip using css animate. However I cannot get the form clickable.
I have tried using z-index on the positioned element.
You can tab into the form and enter data and submit without issue. You just cannot click it.
What am I missing here?
Thank you for your help.
.entry_wrapper {
width: 50%;
margin: 1.5em auto;
}
.entry_wrapper {
-webkit-perspective: 2000;
}
.entry_wrapper:hover .face {
transform: rotateY(180deg);
}
.face {
box-shadow: 5px 5px 20px 5px #000000;
transform-style: preserve-3d;
transition: all 1.0s linear;
backface-visibility: hidden;
width: 100%;
height: 100%;
}
.face .back {
width: 100%;
height: 100%;
position: absolute;
top: 0;
transform: rotateY(180deg);
border: solid white 1px;
border-radius: 5px;
background: grey;
z-index: 30;
}
.entry {
display: block;
position: relative;
width: 100%;
height: auto;
}
.entry_img {
margin: 0 auto;
width: 100%;
height: auto;
}
.entry img {
Width: 100%;
height: auto;
margin-bottom: -5px;
}
.entry_img p {
display: inline;
position: absolute;
bottom: 0;
z-index: 10;
color: white;
text-align: center;
margin: 0;
width: 100%;
background: rgba(0, 0, 0, 0.6);
}
.entry_footer {
width: 100%;
height: 3em;
text-align: center;
margin: 0 auto;
background: rgba(256, 256, 256, 0.8);
}
.comment {
width: 66%;
background: #cccccc;
border: 2px solid #000000;
border-radius: 5px;
margin: 15px auto;
}
.comment p {
margin: 2px 5px;
}
.comment_name {
font-size: .8em;
}
.comment_name span {
display:block;
float:right;
width:50%;
margin-left:10px;
}
.add_comment {
width: 66%;
display: block;
margin: 15px auto;
background: #cccccc;
border: 2px solid #000000;
border-radius: 5px;
z-index: 50;
}
#comment_form {
z-index: 50;
}
<main>
<div class="entry_wrapper">
<div class="face">
<div class="entry">
<div class="entry_img">
<img src="img/family.jpg">
<p>Birth of first daughter Sophia.</p>
</div>
</div>
<div class="entry_footer">
<p>Like?</p>
</div>
<div class="back face">
<div class="comment">
<p> I really like this picture.</p>
<div >
<p class="comment_name">By: Matthew <span class="date">On: Nov 5th, 2014</span></p>
</div>
</div>
<form id="comment_form" action="comment_submit.php">
<input type="submit">
</form>
<textarea name="comment1" class="add_comment" form="comment_form" placeholder="test"></textarea>
</div>
</div>
</div>
<div class="entry_wrapper">
<div class="entry">
<div class="entry_img">
<img src="img/summit.jpg">
<p>I made it to the top!</p>
</div>
</div>
<div class="entry_footer">
<p>Like?</p>
</div>
</div>
</main>
I'm trying to make this web page and it just has so many issues. I cannot center the #titlediv and the navbar sometimes disappears. I'm not gonna lie: it might be a big fix, I'm really not sure. But here's the link if anyone can possibly salvage it:
http://jsfiddle.net/glenohumeral13/c604vbrn/
Code:
<body>
<div id="parallaxish"></div>
<div id="navbar">
<nav>
Item1
Item2
Item3
</nav>
</div>
<div id="contentdiv">
<div id="welcome">
<div id="titlediv">
<h1>Title will go here</h1>
</div>
</div>
<div class="barrier"></div>
<div id="item1">
<h1>Item1</h1>
</div>
<div class="barrier"></div>
<div id="item2">
<h1>Item2</h1>
</div>
</div>
</body>
CSS
* {
margin: 0;
padding: 0;
}
body {
color: #fff;
background-color: #000;
font-family: Helvetica, Arial, sans-serif;
}
img {
max-width: 100%;
height: auto;
}
#parallaxish {
background-image: url('http://24.media.tumblr.com/tumblr_m54j1nIYN21r0k830o1_500.jpg');
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: -1;
background-position: center;
-moz-background-size: cover;
-o-background-size: cover;
-webkit-background-size: cover;
background-size: cover;
width: 100%;
height: auto;
}
#navbar {
float:right;
height: 30px;
margin-right: 100px;
}
nav a {
text-decoration: none;
display: inline;
list-style-type: none;
padding-right: 15px;
padding-top: 10px;
float: left;
-webkit-transition: color 1s ease-out;
-moz-transition: color 1s ease-out;
-o-transition: color 1s ease-out;
transition: color 1s ease-out;
font-weight: 100;
color: #fff;
-webkit-font-smoothing: antialiased;
}
nav a:hover {
color: #16a085;
}
#welcome {
height: 600px;
width: 100%;
text-align: center;
text-transform: uppercase;
background-color: black;
}
#welcome h1, #item1 h1, #item2 h1 {
font-weight: 100;
-webkit-font-smoothing: antialiased;
}
#titlediv {
border: 2px solid #fff;
width: 180px;
margin: auto;
padding: auto auto;
position: absolute;
left: 0;
right: 0;
overflow: auto;
}
.barrier {
height: 120px;
width: 100%;
background: transparent;
}
#item1 {
height: 600px;
width: 100%;
text-align: center;
background-color: white;
color: #16a085;
}
#item1 h1, #item2 h1 {
padding: 5% 0;
}
#item2 {
height: 600px;
width: 100%;
text-align: center;
background-color: black;
color: white;
}
First of all, a demo!
http://jsfiddle.net/ImagineStudios/c604vbrn/10/
What it looks like what you are trying to do is vertically and horizontally center it, in the div, correct?
There is a simple way to do this with css, that i find very useful:
<div id="welcome">
<div id="titlediv">
<h1>Title will go here</h1>
</div>
</div>
First of all, we give position:relative; to the div id="welcome":
/*With your current CSS*/
#welcome {
height: 600px;
width: 100%;
text-align: center;
text-transform: uppercase;
background-color: black;
position:relative;
}
And then, the magic! The <div> id="titlediv" is given position:absolute; and a few other rules:
#titlediv {
border: 2px solid #fff;
width: 180px;
margin: auto;
padding: auto auto;
position: absolute;
width: 180px;
height: 76px;
left: 0;
right: 0;
top:0;
bottom:0;
overflow: auto;
}
This little trick only works if the width and height are declared.
Now, for the nav bar easily fixed:
#navbar {
position:absolute;
top:0;
right:100px;
height: 30px;
z-index:10;
}
And to wrap it all up, a full screen demo!
http://jsfiddle.net/ImagineStudios/c604vbrn/10/embedded/result/
http://stickyjs.com/ will help you!
I
//LOAD THE FILES
<script src="jquery.js"></script>
<script src="jquery.sticky.js"></script>
/RUN THE SCRIPT
<script>
$(document).ready(function(){
$("#navbar").sticky({topSpacing:0});
});
</script>
if i were in your place i'll try to make my page by using a framework like bootstrap or foundation , if you want a lightweight one you can always try skeleton is easy to use & you can find snippets around the web very easily :
http://getbootstrap.com/ |
http://bootsnipp.com/
hopefully i helped you & next time try using google first