Change size of button - html

I have tried everything, but I cannot manage to make the button smaller in the width and height.
.c--anim-btn span {
color: white;
text-decoration: none;
text-align: center;
display: block;
}
.c--anim-btn,
.c-anim-btn {
transition: 0.3s;
}
.c--anim-btn {
height: 64px;
font: normal normal 700 1em/4em Arial, sans-serif;
overflow: hidden;
width: 200px;
background-color: #3b5998;
}
.c-anim-btn {
margin-top: 0em;
}
.c--anim-btn:hover .c-anim-btn {
margin-top: -4em;
}
<!-- HINT: hover over button -->
<div class="c--anim-btn">
<span class="c-anim-btn">
First Text
</span>
<span>
Second Text
</span>
</div>
If someone please can tell me a solution, I would be very grateful.

Change the CSS property of c--anim-btn class
.c--anim-btn span {
color: white;
text-decoration: none;
text-align: center;
display: block;
}
.c--anim-btn,
.c-anim-btn {
transition: 0.3s;
}
.c--anim-btn {
height: 24px; /* change height */
font: normal normal 700 1em/1.6em Arial, sans-serif;
overflow: hidden;
width: 100px; /* change width */
background-color: #3b5998;
}
.c-anim-btn {
margin-top: 0em;
}
.c--anim-btn:hover .c-anim-btn {
margin-top: -1.6em;
}
<!-- HINT: hover over button -->
<div class="c--anim-btn">
<span class="c-anim-btn">
First Text
</span>
<span>
Second Text
</span>
</div>

you need to adjust line height and margin top after change height because of text seen. Comment out onn css please take a look .c--anim-btn and .c--anim-btn:hover
.c--anim-btn span {
color: white;
text-decoration: none;
text-align: center;
display: block;
}
.c--anim-btn, .c-anim-btn {
transition: 0.3s;
}
.c--anim-btn {
height: 128px;
font: normal normal 700 1em/8em Arial,sans-serif; /* 1em/8em means font-size/ line-height */
overflow: hidden;
width: 500px;
background-color: #3b5998;
}
.c-anim-btn{
margin-top: 0em;
}
.c--anim-btn:hover .c-anim-btn{
margin-top: -8em; /*Here you need to adjust after line-height change */
}
<!-- HINT: hover over button -->
<div class="c--anim-btn">
<span class="c-anim-btn">
First Text
</span>
<span>
Second Text
</span>
</div>

Related

Slow down transition top ease of button

I have a button that goes up when hovered. The transition time is supposed to be 1 second but it's not working. Here is the code:
<style>
#talk-to-us {
padding: 10px!important;
height: 43px!important;
width: 148px!important;
background-color: #0ee9f5!important;
display: inline-auto!important;
margin-right: 5px;
position: relative;
transition: top ease 1.0s; /*this is not working*/
}
#talk-to-us:hover {
top: -10px;
text-decoration:underline;
}
#link {
color: white!important;
font-size: 14px!important;
padding: 10px!important;
}
</style>
<button id="talk-to-us">
<b>
<a id="link" href="#">TALK TO US!</a>
</b>
</button>
Any idea what the cause could be?
If you need a transition from something to anything... first you need to give the "something" the transition property. So just add top:0 to the origin. like this:
<style>
#talk-to-us {
padding: 10px!important;
height: 43px!important;
width: 148px!important;
background-color: #0ee9f5!important;
display: inline-auto!important;
margin-right: 5px;
position: relative;
transition: top ease 1.0s; /*this is not working*/
top:0;
}
#talk-to-us:hover {
top: -10px;
text-decoration:underline;
}
#link {
color: white!important;
font-size: 14px!important;
padding: 10px!important;
}
</style>
<button id="talk-to-us">
<b>
<a id="link" href="#">TALK TO US!</a>
</b>
</button>

How can I block a buttons size, independently of its texts size?

so I am trying to do make my buttons like this.
I have tried creating containers for each button group and setting their padding to 50px 60px per say, but that did not work and they still stretch.
I have this:
Here is the code:
.container5 {
background-image: url("servicos.svg");
width: 100vw;
height: 100vh;
background-size: contain;
max-width: 100%;
left: 0;
}
.container5 .underline {
padding-top: 20px;
padding-bottom: 10px;
text-decoration: none;
border-bottom: 5px solid rgb(220,52,52);
}
.container5 h1 {
margin: auto;
line-height: 30px;
vertical-align: middle;
margin-left: 10vh;
weight: 950;
padding-top: 10vh;
font-family: 'Source Sans Pro', sans-serif;
font-size: 50px;
color: #000;
}
.container5 .btn-group {
left: 0;
margin-left: 5vw;
}
.container5 .btn-group button {
color: white;
background-color: #05031b;
font-family: Helvetica, Arial, Sans-Serif;
font-size: 15px;
text-decoration: none;
position: relative;
padding: 40px 35px;
-webkit-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
margin: 0 10px 0 0;
}
.container5 .btn-group .btn-group-ls {
font-size: 10px;
}
.container5 .btn-group2 {
left: 0;
margin-top: 3vh;
padding: 40px 30px;
}
.container5 .btn-group2 button {
color: white;
background-color: #05031b;
font-family: Helvetica, Arial, Sans-Serif;
font-size: 15px;
text-decoration: none;
position: relative;
margin: 0 10px 0 0;
left: 0;
}
.container5 .btn-group3 {
margin-top: 3vh;
}
.container5 .btn-group3 button {
color: white;
background-color: #05031b;
font-family: Helvetica, Arial, Sans-Serif;
font-size: 15px;
text-decoration: none;
position: relative;
padding: 40px 30px;
-webkit-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
margin: 0 10px 0 0;
}
<section class="container5" id="servicos">
<h1><u class="underline">Ser</u>viços </h1>
<div class="btn-group">
<button>VIDEO AULAS</button>
<button>
LIVES DIARIAS
<br>
<div class="btn-group-ls">
(ANALISE DO MERCADO)
</div>
</button>
<button>SALA DE SINAIS</button>
<div>
<div class="btn-group2">
<button>
LIVES SEMANAIS
<br>
<div class="btn-group-ls">
(RESTROSPECTIVA DO MERCADO)
</div>
</button>
<button>
LIVES SEMANAIS
<br>
<div class="btn-group-ls">
(PARA DUVIDAS)
<!-- Edit by tacoshy: Missing a div closing tag here -->
</button>
<button>MATERIAIS DIDATICOS</button>
<div>
<div class="btn-group3">
<button>FERRAMENTAS DE AUXILIO</button>
<button>
PREMIAÇÃO POR
<br>
DESEMPENHO (MENSAL)
</button>
<button>PROGRAMA DE TALENTOS</button>
<div>
<!-- Edit by tacoshy: as you see missing a lot closing tags -->
</section>
How do I make the buttons like those ones from the 1st image? Mine's sizes aren't stable and will change if the sentences are too big. Any ideas guys?
Thank you.
EDIT
I managed to align all of the buttons, however, any guess on how to level the buttons? Those who have more text are a few pixels lower than the rest.
You can apply width and height settings to them. To make them all the same height (regardless of the different text amount in them), also add a min-height setting that's at least as high as the highest button.
To center-align the texts in side them properly you can use display:flex; justify-content: center; align-items: center; on the buttons themselves.`

Search input field like TripAdvisor functionality

I am trying to achieve a similar search form like tripadvisors (at least UI and Front Design speaking) but i have till now a few issues.
On the first photo is how is my search bar with the class name for testing purposes "asdf".
so in the second picture we have the issue, the expandable part of the form being a bit wider than the input search field.
In the third pict if with have the issue if i try to assign the same width of the rest of the form with the input["text"] field of the search form.
Below my basic html and css code.
HTML
<div class="aboutUs">
<div class="textFlexContainer">
<div class="text-box">
<h1 class="heading-primary">
<span class="heading-primary-main">City</span>
<span class="heading-primary-sub">is where summer happens</span>
</h1>
<form class="search-box" action="/search">
<input class="asdf" type="search" placeholder="Explore City">
<div class="search-page">
<h3>Explore City</h3>
<ul class="search-menu-list">
<li>Our Daily Suggestions</li>
<li>Shopping</li>
<li>City Tours</li>
<li>Restaurants</li>
<li>Events</li>
<li>Things to do</li>
</ul>
<h3>Recently Reviewed</h3>
</div>
</form>
</div>
</div>
</div>
And CSS
.search-box{
display: block;
position: relative;
overflow: hidden;
z-index:15;
padding:2rem;
}
.asdf {
width: 80%;
padding:2rem;
border: none;
outline: none;
border-bottom:2px solid white;
margin-top:2.5rem;
font-size: inherit;
background-color: green;
color: #fff;
}
h3{
color:#fff;
margin-top:2rem;
}
.search-page {
height: fit-content;
background-color:green;
text-align: center;
padding:4rem 0;
transition: all 300ms ease-in-out;
display: none;
}
.search-page.visible {
display: block;
transition: all 300ms ease-in-out;
}
.search-page .search-menu-list{
display:flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
}
.search-page .search-menu-list li{
list-style: none;
}
.search-page .search-menu-list li a:hover{
transform: translateY(-1rem);
}
.search-page .search-menu-list li a{
display: inline-block;
color:#fff;
padding:5px;
list-style: none;
text-decoration: none;
margin-right: 2.5rem;
transition: all 300ms ease-in-out;
border: solid 2px white;
border-radius: 1rem;
padding: 11px 13px 11px 14px;
margin: 10px;
}
.aboutUs{
display: grid;
background-image: linear-gradient(to right bottom, rgba(53, 170, 120, 0.8), rgba(20, 139, 102, 0.8)) ,url(../img/ch4.jpg);
background-size: cover;
background-position: center;
grid-column-start: 1;
grid-column-end: 13;
grid-row-start: 2;
grid-row-end: 3;
}
.textFlexContainer{
display:flex;
align-self: center;
}
.heading-primary {
color:#fff;
text-transform: uppercase;
}
.heading-primary-main{
display: block;
font-size: 6rem;
font-weight: 400;
letter-spacing: 3.5rem;
}
.heading-primary-sub {
display: block;
font-size: 2rem;
font-weight: 400;
letter-spacing: 1.8rem;
}
.text-box {
display: inline-block;
/* This content should just be in the normal flow of the page */
/*
position: absolute
top:30%;
left:50%;
transform: translate(-50% ,-50%);
*/
text-align: center;
/* Because we're using flexbox, we can center the content both horizontally and vertically
* using this declaration
*/
margin: auto;
}
Additionaly i would love if when i click on the search bar field and the form is expanding to not have the letters above the search bar to getting squeezed on the top.
Not entirely sure what you need here but here's a fix for image 3. Adding 2 lines of code to your .search-page fixes the alignment issue.
.search-page{
height: fit-content;
background-color:green;
width:80%;
text-align: center;
padding:4rem 0;
transition: all 300ms ease-in-out;
display: all;
}
The width sets it to line up with the size of the text input of the form. The margin: 0 auto; is a good way to quickly center elements in css.
I can't see the expandable part when I tested your code but have you tried changing the width to become small and then do a margin-left to move de expandable part and align it with the search?

Pbm with animation on hover with solid background

I'm working on my very own website and I used this codepen
https://codepen.io/nikolamitic/pen/vpNoNq to create an animation on my name.
It works fine until I want to reduce the line-height of my elements without they hide each other (see the "j" and "p" caracters).
You can take a look here :
h1{
display:inline-block;
font-family: sans-serif;
font-size: 110px;
letter-spacing: 3px;
margin:0;
line-height: 90px;
}
h1 p{margin:0;}
/*************************************************/
/************* LETTER ANIMATION HOVER ************/
/* Thanks to https://codepen.io/nikolamitic/pen/vpNoNq */
.letter-anim{
position: relative;
color: #fff;
background-color: #222;
overflow: hidden;
cursor: pointer;
}
.letter-anim .letter-anim-dynamic,
.letter-anim .letter-anim-dynamic p {
display: flex;
justify-content: left;
align-items: center;
position: absolute;
top:0;
left:0;
right:0;
bottom:0;
z-index: 2;
transition: all ease 0.7s;
}
.letter-anim .letter-anim-dynamic{
background-color: #fff;
color: #222;
overflow: hidden;
}
.letter-anim.active .letter-anim-dynamic,
.letter-anim:hover .letter-anim-dynamic {
transform: translateX(100%);
}
.letter-anim.active .letter-anim-dynamic p,
.letter-anim:hover .letter-anim-dynamic p {
transform: translateX(-100%);
}
.letter-anim-static{
font-size: 76px;
}
<h1 class="letter-anim h1-firstname">
<span class="letter-anim-static">
レ・ジェーン<br/>
</span>
<span class="letter-anim-dynamic">
<p>Lejeune</p>
</span>
</h1>
<br/>
<h1 class="letter-anim h1-lastname">
<span class="letter-anim-static">
ジョゼーフ<br/>
</span>
<span class="letter-anim-dynamic">
<p>Joseph</p>
</span>
</h1>
Thank for you help !
Just add margin-top : -10px in css for this css property letter-anim.letter-anim-dynamic p
<h1 class="letter-anim h1-firstname">
<span class="letter-anim-static">
レ・ジェーン<br/>
</span>
<span class="letter-anim-dynamic">
<p>Lejeune</p>
</span>
</h1>
<br/>
<h1 class="letter-anim h1-lastname">
<span class="letter-anim-static">
ジョゼーフ<br/>
</span>
<span class="letter-anim-dynamic">
<p>Joseph</p>
</span>
</h1>
h1{
display:inline-block;
font-family: sans-serif;
font-size: 110px;
letter-spacing: 3px;
margin:0;
line-height: 90px;
}
h1 p{margin:0;}
/*************************************************/
/************* LETTER ANIMATION HOVER ************/
/* Thanks to https://codepen.io/nikolamitic/pen/vpNoNq */
.letter-anim{
position: relative;
color: #fff;
background-color: #222;
overflow: hidden;
cursor: pointer;
}
.letter-anim .letter-anim-dynamic,
.letter-anim .letter-anim-dynamic p {
display: flex;
justify-content: left;
align-items: center;
position: absolute;
top:0;
left:0;
right:0;
bottom:0;
z-index: 2;
transition: all ease 0.7s;
margin-top: -10px;
}
.letter-anim .letter-anim-dynamic{
background-color: #fff;
color: #222;
overflow: hidden;
}
.letter-anim.active .letter-anim-dynamic,
.letter-anim:hover .letter-anim-dynamic {
transform: translateX(100%);
}
.letter-anim.active .letter-anim-dynamic p,
.letter-anim:hover .letter-anim-dynamic p {
transform: translateX(-100%);
}
.letter-anim-static{
font-size: 76px;
}
It looks like the container for the h1 is just bit too small for the characters that are inside.
Try adding a simple padding:10px to h1 and the container should have more space for them.

How to make clickable area for html input larger

So I'm working on making a website's navbar responsive: http://codepen.io/anon/pen/VvmpKx
The navbar has a simple (currently nonfunctional) search input field.
<nav>
...
<form class="search">
<input type="text" size="15" placeholder="Search..." />
</form>
</nav>
At about 750 px, I reduce the font size and increase the height of the nav bar, to make it easier to click the navbar links. This works great, except for the search bar.
Is there a way to make the area above and below the search input clickable, as if the user had clicked on the input itself, as it is for the category links?
I'd prefer solutions using only css, but javascript or jquery is also acceptable.
Sure! You can add a label around the input, then style the label to have 100% height:
/* New style */
nav form.search label {
height: 100%;
display: block;
}
/* Untouched styles */
nav {
font-family: "Merriweather Sans", "Tahoma", "Trebuchet MS", sans-serif;
background-color: #333;
margin: 0 0 1em 0;
height: 2em;
padding: 0 0.3em;
}
nav a {
color: #FFF;
text-decoration: none;
padding: 0 0.5em;
margin: 0 0.1em;
display: inline-block;
height: 100%;
vertical-align: middle;
line-height: 2em;
transition: background-color .2s ease-in-out;
}
nav a.news:hover {
background-color: #0581C1;
}
nav a.comm:hover {
background-color: #228B22;
}
nav a.variety:hover {
background-color: #9966CC;
}
nav a.sports:hover {
background-color: #DAA520;
}
nav a.satire:hover {
background-color: #B31B1B;
}
nav a:active {
background: #777;
}
nav form.search {
float: right;
display: inline;
vertical-align: middle;
line-height: 2em;
padding: 0 0.5em;
}
nav form.search input {
border-radius: 5px;
width: 5em;
height: 1em;
transition: width .3s ease-in-out, height .3s ease-in-out, margin-right .3s ease-in-out;
}
nav form.search input:focus {
width: 10em;
height: 1.2em;
margin-right: -0.2em;
}
#media (max-width: 750px) {
nav {
font-size: 0.8em;
height: 5em;
}
nav a,
nav form.search {
line-height: 5em;
}
}
<nav>
<span>Site title</span>
<a class="news" href="#"><span>Category</span></a>
<a class="comm" href="#"><span>Category</span></a>
<a class="variety" href="#"><span>Category</span></a>
<form class="search">
<label>
<input type="text" size="15" placeholder="Search..." />
</label>
</form>
</nav>
Put an event listener on the encapsulating form:
var backgroundForm = document.getElementById('background');
var search = document.getElementById('search');
backgroundForm.addEventListener('click', function(){
search.focus();
});
Updated example
You can add some Jquery for that.
Some thing like this will do the trick.
$(window).ready(function(){
$("form.search").click(function(){
$(this).find("input").focus();
});
});
You can make it with CSS pseudo classes. It's especially suitable for inputs with small targets - checkboxes/radios. Unfortunately, this does not work on IE:
input[type="checkbox"] {
position: relative;
}
input:before {
content: '';
cursor: pointer;
display: block;
position: absolute;
top: -10px;
right: -10px;
bottom: -10px;
left: -10px;
}
http://jsfiddle.net/gkaraliunas/0r0ag1ad/?utm_source=website&utm_medium=embed&utm_campaign=0r0ag1ad