How to make two buttons the same size? - html

How can I fix this because if the text is long the button will be longer.
button {
border: none;
padding: 1.1em 6.5em;
background: #00abc6;
color: #fff;
font-family: 'TitilliumText22LRegular', Arial, sans-serif;
font-weight:bold;
font-size: 1.1em;
border-radius: 0px;
}
button:hover {
background: #3E3E3E;
}
<button class="md-trigger" data-modal="modal-1">Login</button>
<center><p>Or</p></center>
<button class="md-trigger" data-modal="modal-2">Register</button>

you need to set a width and height for your button and to centre text horizontally and vertically use the following:
width:120px;
height:50px;
text-align:center;
line-height:1.1em;
font-size:1.1em;
width and height can be set to match your desired measurements.
This can be used for future demonstration:
https://jsfiddle.net/j9njkwkq/
EDIT:
of course you can add cursor:pointer in order to get the "right" button effect on a browser.

In this case you should use. min-width attribute.
Use min-width:100px

Add width to the style definition, for example:
max-width: 100px;
or just:
width: 100px;
https://jsfiddle.net/ghc9aw3w/
Of course you have to adjust the value to the text's required length.

button {
border: none;
padding: 1.1em 6.5em;
background: #00abc6;
color: #fff;
font-family: 'TitilliumText22LRegular', Arial, sans-serif;
font-weight:bold;
font-size: 1.1em;
border-radius: 0px;
width:200px
}
button:hover {
background: #3E3E3E;
}
<button class="md-trigger" data-modal="modal-1">Login</button>
<center><p>Or</p></center>
<button class="md-trigger" data-modal="modal-2">Register</button>

You could make a wrapper and than set the width to 100%
#login {
width: 300px;
}
button {
border: none;
padding: 1.1em 6.5em;
background: #00abc6;
color: #fff;
font-family: 'TitilliumText22LRegular', Arial, sans-serif;
font-weight:bold;
font-size: 1.1em;
border-radius: 0px;
width: 100%;
}
button:hover {
background: #3E3E3E;
}
<div id='login'>
<button class="md-trigger" data-modal="modal-1">Login</button>
<center><p>Or</p></center>
<button class="md-trigger" data-modal="modal-2">Register</button>
</div>

Give "width" for the class .md-trigger or button to make that same even if long text is entered.

For perfect styling wrap the contents inside a div
https://jsfiddle.net/ghc9aw3w/2/
<div class="btnwrap">
<button class="md-trigger" data-modal="modal-1">Login</button>
<center><p>Or</p></center>
<button class="md-trigger" data-modal="modal-2">Register</button>
</div>
then the style would be
.btnwrap{
width:200px;
overflow:hidden;
}
button {
width:100%;
display:block;
border: none;
padding: 1.1em 5em;
background: #00abc6;
color: #fff;
font-family: 'TitilliumText22LRegular', Arial, sans-serif;
font-weight:bold;
font-size: 1.1em;
border-radius: 0px;
text-align:center;
}
button:hover {
background: #3E3E3E;
}

Related

Background-image and border

I have a background image and I will wish add a border and a background white with a width of 18cm.Here is below an exemple:
We have the background image with a border and a background white inside..
Here is my realization below...
My result is still mediocre I know but how to do to create the same thing?
I search to create a border with a background white...
HTML
<div class="img_reg">
<div class="contenair_reg">
<span class="regtxtcolor"><i class="far fa-address-card"> Personal Information:</i></span>
<p>Please use English letters and numbers in all field for registration before creating an account.</p>
</div>
</div>
CSS
.contenair_reg{
padding-top: 60px;
padding-left: 320px;
}
.regtxtcolor{
font-size: 26px;
font-family: 'Open Sans', sans-serif;
text-transform: uppercase;
color: #C22312;
font-weight: bold;
}
Is it my HTML blocks are OK ?
hi what I did was enclosed the < p > element in a div with class .reg_content_container so I could add a border below it. Please run snippet, thanks.
body{
height:100%;
background:url('https://edmontongazette.com/wp-content/uploads/2018/07/California.jpg');
background-size:cover;
}
.body_padding{
padding:60px 30px 0px 30px;
}
.contenair_reg{
padding:15px;
background-color:white;
border-radius:5px;
}
.regtxtcolor {
font-size: 26px;
font-family: 'Open Sans', sans-serif;
text-transform: uppercase;
color: #C22312;
font-weight: bold;
}
.contenair_reg p{
margin-bottom:8px;
}
.reg_content_container{
border-bottom:3px solid #C22312;
}
<html>
<body>
<div class="body_padding">
<div class="contenair_reg">
<span class="regtxtcolor"><i class="far fa-address-card"> Personal Information:</i></span>
<div class="reg_content_container">
<p>Please use English letters and numbers in all field for registration before creating an account.</p>
</div>
</div>
</div>
</body>
</html>
You probably need to set a background-color and a margin. Use the padding for the background, not for separate from it's container.
.contenair_reg
Also you need a border bottom to the p tag, try something like this codepen
.img_reg {
background-image: url(https://static1.squarespace.com/static/5459ec52e4b04d305f68f1ed/t/548a8e17e4b0dd3cb0247e7b/1418366488991/?format=2500w);
width: 100vw;
height: 100vh;
}
.contenair_reg{
position: absolute;
top: 50%;
left: 50%;
width: 70%;
height: 20%;
padding: 30px;
background-color: white;
transform: translate(-50%, -50%);
border-radius: 6px;
}
.regtxtcolor{
font-size: 26px;
font-family: 'Open Sans', sans-serif;
text-transform: uppercase;
color: #C22312;
font-weight: bold;
}
p{
padding-bottom: 5px;
border-bottom: 2px solid #C22312;
}
.box{
background:url('https://preview.ibb.co/kv4XHU/66.jpg');
background-size:cover;
background-repeat:no-repeat;
height: 300px;
}
.box { padding: 150px 35px 0 35px; }
.box-content {
padding:15px;
background-color: #ffffff;
border-radius: 5px;
}
.box-icon {
font-size: 24px;
font-family: 'Open Sans', sans-serif;
text-transform: uppercase;
color: #C22312;
font-weight: 700;
}
.box-content p { margin-bottom: 12px; }
.box-text{ border-bottom:3px solid #C22312; }
<div class="box">
<div class="box-content">
<span class="box-icon"><i class="far fa-address-card"> Personal Information:</i></span>
<div class="box-text">
<p>Please use English letters and numbers in all field for registration before creating an account.</p>
</div>
</div>
</div>

How can my button's position be centered without any kind of "margin cheat"?

How can I place my button in the center without any kind of "margin cheat" (for example setting margin-left: 525px;)?
HTML
<div id="banner">
<div id="bannerContainer">
<h1>H1 tag</h1>
Products
</div>
</div>
CSS
.bannerButton {
border: 2px solid #fff;
color: #fff;
font-weight: 300;
font-family: 'Raleway';
font-size: 20px;
display: inline-block;
background-color: rgb(63, 127, 191);
padding: 18px 60px 18px 50px;
margin-bottom: 50px;
margin-top: 50px;
position: relative;
margin-left: 525px;
}
.bannerButton:hover {
text-decoration: none;
background: #eaf;
color: #fff;
}
I've tried making it sit in the center but it didn't work out so well without me setting margin-left; 525px;, which in my case, centers the button under the text, please help me remove this "margin cheat" and do it in the right way.
The a act like text it means when you give text-align:center; to its parent, it will be placed in center of its parent.
You don't need to give margin to the a element. You can use text-align:center;.
#bannerContainer
{
text-align:center;
}
.bannerButton {
border: 2px solid #fff;
color: #fff;
font-weight: 300;
font-family: 'Raleway';
font-size: 20px;
display: inline-block;
background-color: rgb(63, 127, 191);
padding: 18px 60px 18px 50px;
margin-bottom: 50px;
margin-top: 50px;
position: relative;
}
.bannerButton:hover {
text-decoration: none;
background: #eaf;
color: #fff;
}
<div id="banner">
<div id="bannerContainer">
<h1>H1 tag</h1>
Products
</div>
</div>
If you set the position of the button to absolute, give it a set width, and add this it should center:
left: 50%; right: 50%;
Have you try this:
<center>Products</center>
I am not sure whether it is helpful to you..

Place two form elements inline

I currently have 1 form with 2 elements inside it (an email input and a submit button). This form looks like this for me:
But some of my associates seem to have it looking like this:
My relevant HTML looks like this:
<header>
<div class="wrap nopad">
<h1>Share and Listen to Music.</h1>
<form>
<input type="email" placeholder="Email address to get started"><input type="submit" value="Get Started">
</form>
</div>
</header>
and the relevant CSS looks like this:
body {
background-color: #1B1B1E;
color: #fff;
margin:0;
padding: 0;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
}
.wrap {
width:685px;
padding:0 15px;
margin:0 auto;
display: block;
}
.wrap.nopad {
width:700px;
padding: 0;
}
header {
width:100%;
padding:200px 0 100px;
background-color: #2de6c0;
display: block;
}
header .wrap h1 {
color:#000;
text-align: center;
display: block;
font-weight:bolder;
text-transform: uppercase;
font-size:45.4px;
letter-spacing: 0px;
}
header .wrap h1 span {
text-decoration: underline;
}
header form {
padding:20px 0 0;
width:660px;
margin:0 auto;
}
input[type=email] {
color:#000;
padding:20px;
display: inline-block;
outline: 0;
border: 0;
width:470px;
text-transform: uppercase;
font-size:24px;
font-weight: 500;
}
input[type=submit] {
background-color: #000;
color:#FFF;
text-transform:uppercase;
font-size:16px;
padding:25px 20px;
display: inline-block;
font-weight:500;
outline: 0;
border: 0;
cursor: pointer;
float: right;
}
Could you please point me in the right direction so I can fix my code to work in all browsers and be inline.
Thanks!
Fiddle
Reduce the padding of black submit button button.
input[type=submit]
{
padding: 25px 16px;
}
See the Demo
Demo2
It ll give you best design
input email button --> Width:71.4%
submit button ---> Remove left and right padding and add width 22.54%

How can I align a text that has a specific width at the center of a div?

This is the fiddle demo
I want to align group 2 to the center of the div so that the bottom border of the div be aligned to the middle of the text. However when I assign the text a width, it cannot be aligned to the center. If I remove the width, then the text takes up the whole line, so that the bottom border of the div cannot been seen. How shall I solve this problem?
HTML code:
<div class="group-name">
<p>Group1</p>
</div>
CSS:
.group-name{
border-bottom: 1px solid #979797;
}
.group-name p{
display:block;
margin-bottom: -9px;
width:100px;
font-family: "Open Sans",sans-serif;
text-align:center;
font-size: 18px;
color: #16A085;
background-color: #F8F8F8;
}
from your description, it looks like you are trying to put your text centered and in the middle of the border of the parent div:
.group-name{
border-bottom: 1px solid #979797;
width:100%;
height: 10px;
}
.group-name p{
display:block;
margin: 0 auto -7px ;
background: #fff;
width:100px;
text-align:center;
}
http://jsfiddle.net/92Uu7/4/
If you want it in the center together with a width you can do.
group-name{
border-bottom: 1px solid #979797;
}
.group-name p{
display:block;
margin: 0 auto;
margin-bottom: -11px;
width: 60px;
font-family: "Open Sans",sans-serif;
font-size: 18px;
color: #16A085;
background-color: #F8F8F8;
}
JSFiddle
You need to use margin:auto (or margin-left:auto; margin-right:auto;) to align block level elements to the middle of the line if you are setting a width on them
Example
Otherwise you could make the element an inline-block element and then give it a width:
inline-block
You can try to give the .group-name p -> margin: 0 auto;
.group-name p{
display:block;
margin-bottom: -9px;
width:100px;
/* add this line */
margin: 0 auto;
font-family: "Open Sans",sans-serif;
text-align:center;
font-size: 18px;
color: #16A085;
background-color: #F8F8F8;
}
Just use text-align property
text-align:center;
DEMO
just add text-align to your css class like this :
.group-name{
border-bottom: 1px solid #979797;
text-align:center;
}
fiddle demo
Refer to this JS Fiddle
.group-name {
border-bottom: 1px solid #979797;
}
.group-name p {
display:block;
margin-bottom: -9px;
text-align: center;
font-family:"Open Sans", sans-serif;
font-size: 18px;
color: #16A085;
background-color: #F8F8F8;
}
Use text-align
text-align: center;
You talk about group 2 but it is nowhere in your code?
try adding text-align and text-decoration properties
.group-name p{
display:block;
margin-bottom: -9px;
font-family: "Open Sans",sans-serif;
font-size: 18px;
color: #16A085;
background-color: #F8F8F8;
text-align:center;
text-decoration:underline;
}
Update following CSS -
.group-name{
border-bottom: 1px solid #979797;
text-align:center;
}
use text-align property
.group-name{
border-bottom: 1px solid #979797;
text-align:center;
}

Simple CSS issue, styling the button size

I have a button that has only one letter in it. this is the HTML for it:
<button type="button" class="clicker">X</button>
I need to resize that button to make it smaller as much as I need, and also to keep that letter following the size of the button.
I have tried the following css andit resizes the button, but the text is not following. It is either at the bottom of the button or not visible at all.
.clicker {
float: right;
font-family:"Calibri",Arial,Sans Serif;
font-size:1.0em;
line-height: 30px;
color:red;
text-align: center;
wordwrap: center;
text-shadow:1px 1px 1px #FFFFFF;
width: 30.0px;
height: 25.0px;
}
Reduce the line-height to 23px
http://jsfiddle.net/GfETQ/1/
I don't think you need font-size and line-height properties. Use vertical-align instead.
.clicker {
font-family: "Calibri", Arial, Sans Serif;
font-size: 1.0em;
color:red;
text-shadow: 1px 1px 1px #FFFFFF;
width: 30px;
height: 25px;
vertical-align: middle;
}
Fiddle:- http://jsfiddle.net/7wCLu/
It's just becuase of your line-height. Remove it and it works :)
Fiddle.
CSS:
.clicker {
float: right;
font-family:"Calibri", Arial, Sans Serif;
font-size:1.0em;
color:red;
text-align: center;
wordwrap: center;
text-shadow:1px 1px 1px #FFFFFF;
width: 30.0px;
height: 25.0px;
}
If you change to line-height: 20px; then it will center.