#buttoncontainer {
position: absolute;
top: 15%;
left: 23%;
width: 200px;
height: 500px;
}
.buttons {
position: absolute;
display: block;
width: 70px;
height: 70px;
font-family: DancingScript-Regular;
font-size: 100%;
padding-top: 50px;
background-color: rgba(255,255,255,.0);
padding: 15px 15px;
border: 5px solid white;
border-radius: 70px;
box-shadow: 0px 0px 5px 5px #000000, 0 0 5px 5px #888 inset;
left: 15%;
-webkit-transition: all .3s ease-in-out;
-moz-transition: all .3s ease-in-out;
}
.buttonText {
text-align: center;
display: block;
padding: 25px;
width: 70px;
height: 70px;
font-size: 100%;
text-decoration: none;
color: white;
}
#b11 {
top: 30px;
}
#b22 {
top: 170px;
}
#b33 {
top: 305px;
}
<div id="buttoncontainer">
<div class="buttons" id="b11">
Upload
</div>
<div class="buttons" id="b22">
Refresh
</div>
<div class="buttons" id="b33">
Logout
</div>
</div>
I am trying to make the element fill up its parent container. But for some reason it doesn't align itself- as a whole block element inside/center of it's container, but instead pushes itself downwards and to the right. Can't figure out what I am doing wrong.
EDIT: I forgot to mention that I need the padding to center the text vertically in the bubble. I also tried padding-top: 25px; an still no success on centering the a block element.
EDIT2: I added text-align: center which centers the text correctly in the a element, but again the a element is not centering inside the div.
Here is a Working Demo
Do this in your CSS -
.buttons { text-align: center;
position: absolute;
display: block;
width: 70px;
height: 70px;
font-family: DancingScript-Regular;
font-size: 100%;
padding-top: 50px;
background-color: rgba(255,255,255,.0);
padding: 15px 15px;
border: 5px solid white;
border-radius: 70px;
box-shadow: 0px 0px 5px 5px #000000, 0 0 5px 5px #888 inset;
left: 15%;
-webkit-transition: all .3s ease-in-out;
-moz-transition: all .3s ease-in-out;
}
.buttonText { /*
width: 70px;
height: 70px;*/
display: inline-block;
padding: 18px 0 0 0;
font-size: 100%;
text-decoration: none;
color: black;
}
This centers your text vertically and horizontally in the center of the button.
.buttonText {
text-align: center;
line-height: 70px;
vertical-align:middle;
display: block;
margin: auto auto;
font-size: 100%;
text-decoration: none;
color: white;
}
Hope this helps!
(EDIT: Adjust your line height to the height of the button. vertical-align:middle; will center it vertically)
Remove padding from class .buttonText
Add line-height: 70px;, text-align: center; to center the links.
.buttonText {
display: block;
line-height: 70px;
text-align: center;
padding: 0; /*Change padding to 0*/
width: 70px;
height: 70px;
font-size: 100%;
text-decoration: none;
color: white;
}
Here's a Fiddle
Remove this in your CSS:
.buttonText {padding: 25px;}
Make it as:
.buttonText {padding: 0;}
Thank you all for the suggestions....I finally got it to work with:
.buttonText {
margin-left: -23px;
margin-top: -23px;
position: absolute;
text-align: center;
padding: 28px;
padding-top: 50px;
padding-bottom: 50px;
font-size: 100%;
text-decoration: none;
color: white;
}
Not sure why this one gave me such a hard time...I usually don't have issues when doing buttons like these.
Related
I tried adding the Paypal smart button to my first project. When the Debit or Credit card button is pressed, the text above it goes through the navbar.
I tried adding additional blank space to the background image, but it did not work.
Is there a way to extend the blank space already made by the Paypal button script?
What can I do to fix it?
Navbar problem
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
.header{
min-height: 100vh;
width: 100%;
background-image: linear-gradient(rgba(4,9,30,0.4),rgba(4,9,30,0.4)),url(slike/slika\ 2.JPG);
background-position: center;
background-size: 100%;
position: relative;
}
nav{
display: flex;
padding: 2% 6%;
justify-content: space-between;
align-items: center;
}
nav img{
width: 500px;
}
.nav-links{
flex: 1;
text-align: right;
}
.nav-links ul li{
list-style: none;
display: inline-block;
padding: 8px 20px;
position: sticky;
}
.nav-links ul li a{
color: #7814ac;
text-decoration: none;
font-size: 30px;
font-family: 'Lora', serif;
}
.nav-links ul li::after{
content: "";
width: 0%;
height: 2px;
background: white;
display: block;
margin: auto;
transition: 0.5s;
}
.nav-links ul li:hover::after{
width: 100%;
}
.text-box{
width: 90%;
color: white;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
text-align: center;
margin-top: 200px;
}
.text-box h1{
font-size: 62px;
}
.text-box p{
margin: 10px 0 40px;
font-size: 36px;
color: white;
}
.hero-btn{
display: inline-block;
text-decoration: none;
color: white;
border: 1px solid white;
padding: 12px 34px;
font-size: 24px;
background: transparent;
position: relative;
cursor: pointer;
margin-bottom: 5px;
}
.hero-btn:hover{
border: 1px solid #7814ac;
background: #7814ac;
transition: 1s;
}
The problem would appear to be the container in which all that text is located. Perhaps it has a fixed position or height. The black debit/credit card button needs to be rendered in a container that can expand normally. If for some reason you are not able to change the site's CSS to allow this, you can disable the black button with &disable-funding=card. Other buttons will open the PayPal window normally.
So, it's my first time getting into HTML/CSS and naturally, I'm having problems with certain parts.
I made a "Contine" button in my setup.html and gave it a class so I can style it in my styles.css, now the problem is that text-align center doesnt work on the button. I also have a "Start" button in my index.html, but strangely text-align center works there. I tried giving both buttons the same class and different classes. I'm not sure what to do at this point in time.\
My Button in HTML:
<div class="startcontainer">
<a href="./home.html">
<button id="continue"><span>Continue</span></button>
</a>
</div>
My CSS:
.startcontainer {
position: fixed;
border-radius: 5px;
width: calc(100% - 20px);
height: calc(100% - 120px);
left: 10px;
right: 10px;
bottom: 3%;
margin-bottom: 10px;
padding: 0px;
background-color: #1F1F1F;
float: middle;
text-align: center;
}
.startcontainer a {
position: relative;
display: block;
margin: 0 auto;
top: 40%;
text-decoration: none;
border: 0;
}
.startcontainer a #continue {
position: relative;
max-width: 280px;
max-height: 60px;
line-height: 60px;
padding: 10px 100px;
font-size: xx-large;
background-color: #1F1F1F;
color: #FFFFFF;
opacity: .87;
line-height: normal;
font-family: 'Open Sans', sans-serif;
border: 5px solid #8644A1;
border-radius: 45px;
display: block;
margin: 0 auto;
top: 40%;
transition: 0.4s;
outline: 0;
cursor: pointer
}
.startcontainer a #continue span {
display: block;
line-height: 30px;
}
.startcontainer a #continue:hover {
background-color: #8644A1;
}
Like I said the #contine part in my styles.css is the exact same for the "start" button, but it only works for the start button.
Problem is with max-width: 280px; and padding: 10px 100px; of button.
you are giving padding of 200px on the horizontal scale and then you are limiting button width to 280px. which leaves only 80px for text within. Remove button width for a better look of a button. Alternatively, you can trade off any of the CSS property over others.
.startcontainer {
position: fixed;
border-radius: 5px;
width: calc(100% - 20px);
height: calc(100% - 120px);
left: 10px;
right: 10px;
bottom: 3%;
margin-bottom: 10px;
padding: 0px;
background-color: #1F1F1F;
float: middle;
text-align: center;
}
.startcontainer a {
position: relative;
display: block;
margin: 0 auto;
top: 40%;
text-decoration: none;
border: 0;
}
.startcontainer a #continue {
position: relative;
/* max-width: 280px; */
max-height: 60px;
line-height: 60px;
padding: 10px 100px;
font-size: xx-large;
background-color: #1F1F1F;
color: #FFFFFF;
opacity: .87;
line-height: normal;
font-family: 'Open Sans', sans-serif;
border: 5px solid #8644A1;
border-radius: 45px;
display: block;
margin: 0 auto;
top: 40%;
transition: 0.4s;
outline: 0;
cursor: pointer
}
.startcontainer a #continue span {
display: block;
line-height: 30px;
}
.startcontainer a #continue:hover {
background-color: #8644A1;
}
<div class="startcontainer">
<a href="./home.html">
<button id="continue"><span>Continue</span></button>
</a>
</div>
I have a navigation at the bottom of a page. Everything works fine and how I want it to except for one small bug and I can't seem to work out a solution...
When the page name is long and you view it on an iPad size screen, the name goes onto two lines - which is fine - how ever I would like the adjacent button to match the height (so they both stay the same height) and to both stay horizontally aligned to the centre.
Ive tried a few different things like display table and table cell, flex etc. but I can't seem to work out a solution that works properly.
Any suggestions on how I can do this...?
.footerNav-wrapper {
width: 100%;
background-color: #000;
padding: 35px 0;
z-index: 9000;
position: relative;
}
.footerNav {
width: 90%;
max-width: 1000px;
margin: 0 auto;
}
.navArrow-left {
float: left;
margin: 0;
position: absolute;
top: 30%;
left: 10px
}
.navArrow-right {
float: right;
margin: 0;
position: absolute;
top: 30%;
right: 10px;
}
.footerNav a {
width: 49%;
font-family: 'ABCSans-Regular', Arial, sans-serif;
border: 1px solid #fff;
background-color: #000;
color:#ffc600;
margin: 0;
text-align: center;
font-size: 14px;
line-height: 18px;
letter-spacing: 0px;
cursor: pointer;
-webkit-transition: all .5s;
transition: all .5s;
text-decoration: none;
box-sizing: border-box;
position: relative;
}
.footerNav a:hover {
border: 1px solid #ffc600;
background-color: #ffc600;
color: #000;
text-decoration: none;
}
.left {
float: left;
text-align: left !important;
padding: 15px 15px 12px 45px;
}
.right {
float: right;
text-align: right !important;
padding: 15px 45px 12px 15px;
}
<div class="footerNav-wrapper">
<nav class="footerNav">
<a href="#" class="left">
<img src="images/arrow-left-white.png" class="navArrow-left" alt="Previous page">
PREVIOUS PAGE NAME
</a>
<a href="c#" class="right">
NEXT PAGE NAME - THIS IS AN EXTRA LONG NAME
<img src="images/arrow-right-white.png" class="navArrow-right" alt="Next page">
</a>
<div style="clear:both;"></div>
</nav>
</div>
i used display:flex; on .footerNav and added margin to classes left and right.
.footerNav-wrapper {
width: 100%;
background-color: #000;
padding: 35px 0;
z-index: 9000;
position: relative;
}
.footerNav {
width: 90%;
max-width: 1000px;
margin: 0 auto;
display:flex;
}
.navArrow-left {
float: left;
margin: 0;
position: absolute;
top: 30%;
left: 10px
}
.navArrow-right {
float: right;
margin: 0;
position: absolute;
top: 30%;
right: 10px;
}
.footerNav a {
width: 49%;
font-family: 'ABCSans-Regular', Arial, sans-serif;
border: 1px solid #fff;
background-color: #000;
color:#ffc600;
text-align: center;
font-size: 14px;
line-height: 18px;
letter-spacing: 0px;
cursor: pointer;
-webkit-transition: all .5s;
transition: all .5s;
text-decoration: none;
box-sizing: border-box;
position: relative;
}
.footerNav a:hover {
border: 1px solid #ffc600;
background-color: #ffc600;
color: #000;
text-decoration: none;
}
.left {
float: left;
text-align: left !important;
padding: 15px 15px 12px 45px;
margin-right: 1%;
}
.right {
float: right;
text-align: right !important;
padding: 15px 45px 12px 15px;
margin-left: 1%;
}
<div class="footerNav-wrapper">
<nav class="footerNav">
<a href="#" class="left">
<img src="images/arrow-left-white.png" class="navArrow-left" alt="Previous page">
PREVIOUS PAGE NAME
</a>
<a href="c#" class="right">
NEXT PAGE NAME - THIS IS AN EXTRA LONG NAME
<img src="images/arrow-right-white.png" class="navArrow-right" alt="Next page">
</a>
<div style="clear:both;"></div>
</nav>
</div>
You can also use display: table; and display: table-cell; to do that if you need to support really old browsers (http://caniuse.com/#search=flex). However i would recomment using flexbox as GvM pointed out.
There is an interesting article about serveral ways to do what you want to do: https://css-tricks.com/fluid-width-equal-height-columns/
.footerNav-wrapper {
width: 100%;
background-color: #000;
padding: 35px 0;
z-index: 9000;
position: relative;
}
.footerNav {
display: table;
width: 90%;
max-width: 1000px;
margin: 0 auto;
}
.navArrow-left {
float: left;
margin: 0;
position: absolute;
top: 30%;
left: 10px
}
.navArrow-right {
float: right;
margin: 0;
position: absolute;
top: 30%;
right: 10px;
}
.footerNav a {
width: 49%;
font-family: 'ABCSans-Regular', Arial, sans-serif;
border: 1px solid #fff;
background-color: #000;
color:#ffc600;
margin: 0;
text-align: center;
font-size: 14px;
line-height: 18px;
letter-spacing: 0px;
cursor: pointer;
-webkit-transition: all .5s;
transition: all .5s;
text-decoration: none;
box-sizing: border-box;
position: relative;
}
.footerNav a:hover {
border: 1px solid #ffc600;
background-color: #ffc600;
color: #000;
text-decoration: none;
}
.left {
display: table-cell;
text-align: left !important;
padding: 15px 15px 12px 45px;
}
.right {
display: table-cell;
text-align: right !important;
padding: 15px 45px 12px 15px;
}
<div class="footerNav-wrapper">
<nav class="footerNav">
<a href="#" class="left">
<img src="images/arrow-left-white.png" class="navArrow-left" alt="Previous page">
PREVIOUS PAGE NAME
</a>
<div style="display: table-cell; width: 2%;"></div>
<a href="c#" class="right">
NEXT PAGE NAME - THIS IS AN EXTRA LONG NAME
<img src="images/arrow-right-white.png" class="navArrow-right" alt="Next page">
</a>
</nav>
</div>
So, I am working on two sites, and the padding seems to change tremendously on different screens, I was wondering if this was potentially due to the units I am using? Or the specific CSS tag? However, I am hoping someone can figure it out for me
Two bits of code that keep changing:
codepen
.divider {
background-color: #3498db;
padding-top: 5%;
padding-bottom: 5%;
font-family: Open Sans;
font-weight: 300;
text-align: center;
}
.divider h1 {
margin-bottom: 10px;
margin-top: 0%;
padding-top: 20%;
font-weight: 500;
color: white;
}
.divider p {
color: white;
margin-bottom: 5px;
font-family: Open Sans;
text-align: center;
}
.divider button {
padding: 10px;
height: 15%;
cursor: auto;
width: 17%;
margin-top: 30px;
border-radius: 50px;
text-align: center;
color: white;
border: white 1px solid;
background-color: #3498db;
}
.divider button:hover {
background-color: white;
color: black;
transition: all 0.3s ease 0s;
}
<div class="divider">
<h1>See Something You Like?</h1>
<p>Feel free to contact us at any time and we’ll have someone reply to you 6 as soon as possible.
<br>industry's standard dummy text ever since the 1500s
<br>
<br>Whenever you’re ready, email us with the details you want on your website, and we will
<br>respond with a rough price.</p>
<a href="mailto:hello#baseframe.co">
<button>Email</button>
</a>
</div>
on this, the top padding gets super big (or sometimes it gets smaller) on different screens.
codepen
* {
margin: 0 auto;
padding: 0;
}
html {
height: 100%;
}
body {
font-family: 'Open Sans';
font-weight: 400;
height: 100%;
background-color: #ddd;
}
.nav {
background: rgba(0, 0, 0, 0);
position: absolute;
width: 100%;
}
.nav ul {
text-align: right;
vertical-align: middle;
margin-right: 15px;
margin-top: 15px;
font-size: 1.1em;
}
.nav li {
padding-top: 5px;
list-style: none;
display: inline-block;
padding: 15px;
}
.nav a {
margin-top: 17px;
bottom: 0;
display: inline-block;
color: white;
text-decoration: none;
}
.nav a:hover {
color: #3498db;
transition: ease 0.5s all 0s;
}
.nav hr {
opacity: 0.2;
width: 95%;
text-align: center;
}
.nav-logo {
vertical-align: middle;
top: 0;
float: left;
width: 5%;
display: inline-block;
}
.nav-logo img {
width: 250%;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3);
}
/*-------------------Home-Page-------------------*/
.home-page {
background-image: url("http://baseframe.co/getanimus/img/cover1.jpg");
background-size: cover;
background-position: top;
background-attachment: fixed;
padding-bottom: 17%;
text-align: center;
}
.home-page h1 {
color: white;
padding-top: 15%;
font-size: 5em;
text-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3);
}
.home-page input {
cursor: auto;
}
.home-page p {
font-weight: 300;
color: white;
margin-bottom: 15px;
}
button#infl {
background-color: #3498db;
color: white;
font-size: 1em;
width: 15%;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3);
font-family: montserrat;
padding: 15px;
margin: 5px;
border-top-left-radius: 2em;
border-top-right-radius: 2em;
border-bottom-left-radius: 2em;
border-bottom-right-radius: 2em;
border: none;
cursor: auto;
}
button#brands {
background-color: white;
color: #7f8c8d;
font-size: 1em;
width: 15%;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3);
font-family: montserrat;
padding: 15px;
margin: 5px;
border-top-left-radius: 2em;
border-top-right-radius: 2em;
border-bottom-left-radius: 2em;
border-bottom-right-radius: 2em;
border: none;
cursor: auto;
}
button#brands:hover {
opacity: 0.8;
transition: all 0.3s ease 0s;
}
button#infl:hover {
opacity: 0.8;
transition: all 0.3s ease 0s;
}
/*-------------------About-------------------*/
.about {
background-color: white;
padding-bottom: 10%;
}
.about h1 {
text-align: left;
margin-left: 20%;
margin-top: 5%;
}
.about hr {
background-color: #3498db;
height: 5px;
border: none;
margin-top: 2%;
margin-left: 20%;
width: 5%;
text-align: left;
float: left
}
.about p {
margin-left: 20%;
margin-right: 20%;
line-height: 30px;
margin-top: 5%;
text-align: left;
}
<div class="nav">
<ul>
<li class="nav-logo">
<img src="http://baseframe.co/getanimus/img/logo_white.png">
</li>
<li>Home</li>
<li>Influencers</li>
<li>Brands</li>
<li>Contact</li>
<hr>
</div>
<div class="home-page">
<h1>Animus Digital</h1>
<p>Premium Talent Management Agency</p>
<button id="infl">Influencers</button>
<button id="brands">Brands</button>
</div>
this website navigation doesn't align properly with the logo on the left, for some reason. In addition, on a 1920 x 1080 screen, the buttons get pretty wide.
Really appreciate any help on this. Thanks.
The reason why the sizes of those elements changes on different screens is because you use % instead of px. % scales the size with the browser's size.
You should use CSS Media queries
For first case since you are using % in padding, which leads to unexpected behavior in different situations.
For "n%" margin (and padding) to be the same for
margin-top/margin-right/margin-bottom/margin-left, all four have to be
relative to the same base. If top/bottom used a different base than
left/right', then "n%" margin (and padding) wouldn't mean the same
thing on all four sides.
(Also note having the top/bottom margin relative to the width enables
a weird CSS hack that allows you to specify a box with an unchanging
aspect ratio ...even if the box is rescaled.)
% with margin/padding
One of the biggest problems I have with navigation bars is that, whenever trying to put a logo in with a title, I always find that the image resizes itself to much smaller than the text sooner rather than later.
In the case below, I have a title at one end of the navigation/title bar and an image at the other end. When resizing or even on mobile devices, the image becomes very very small.
The html...
<div id="nav">
<p>Crowes</p>
<img src="pic.jpg" />
</div>
..and the CSS
#nav {
background-color: #7E0E0A;
box-shadow: 1px 1px 1px 1px black;
padding: 1%;
font-size: 5vh;
color: white;
font-weight: bold;
font-family: 'Pacifico';
overflow: auto;
width: 100%;
z-index: 1;
}
#nav p {
margin-left: 2%;
margin-top: 1%;
margin-bottom: 1%;
float: left;
color: white;
}
#nav img {
display: inline-block;
width: 6%;
vertical-align: middle;
float: right;
border-radius: 50%;
border: 2px solid white;
margin-right: 3%;
opacity: 0.7;
transition: all 0.2s ease;
}
It's not only just changing the size of the elements, it was also their positioning. It all had to be changed to ems rather than %.
(Nav-specific)
#nav {
background-color: #7E0E0A;
box-shadow: 1px 1px 1px 1px black;
font-size: 2.3em;
color: white;
font-weight: bold;
font-family: 'Pacifico';
overflow: auto;
width: 100%;
z-index: 1;
}
font-size to 2.3em.
(P-specific)
#nav p {
margin: 1.3em;
display: inline-block;
vertical-align: middle;
float: left;
color: white;
}
margin to 1.3em
(Img-specific)
#nav img {
display: inline-block;
height: 2.3em;
vertical-align: middle;
float: right;
border-radius: 50%;
border: 2px solid white;
margin: 1em;
opacity: 0.7;
transition: all 0.2s ease;
}
height to 2.3em, as guided by #MrLister and margin to 1em.