i've been trying all night to center this elements without having them stacked on each other:
I've tried floating them to the left it works, but, they stick to the left side no matter what i did.
HTML:
<div class="center pages clearfix">
<buuton class="center page-number">1</buuton>
<buuton class="center page-number">2</buuton>
<buuton class="center page-number">3</buuton>
</div>
CSS:
.center {
margin-left: auto;
margin-right: auto;
}
.page-number {
display: block;
float: none;
width: 28px;
height: auto;
border-radius: 3px;
background-color: rgba(0, 0, 0, 0.47);
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.34);
text-shadow: 0 2px 5px rgba(0, 0, 0, .5);
font-weight: 400;
line-height: 1.5;
text-align: center;
color: rgba(255, 255, 255, 0.47);
}
just update "display:block" to "display:inline-block" like the below updated css
updated css
.center {
margin-left: auto;
margin-right: auto;
text-align:center;
}
.page-number {
display: inline-block;
float: none;
width: 28px;
height: auto;
border-radius: 3px;
background-color: rgba(0, 0, 0, 0.47);
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.34);
text-shadow: 0 2px 5px rgba(0, 0, 0, .5);
font-weight: 400;
line-height: 1.5;
text-align: center;
color: rgba(255, 255, 255, 0.47);
}
demo
Try this: https://jsfiddle.net/uo23L4n4/
use inline-block instead of block for the buttons.
use text-align:center
<button class=" page-number">1</button>
.center {
margin-left: auto;
margin-right: auto;
text-align: center;
}
.page-number {
display: inline-block;
float: none;
width: 28px;
height: auto;
border-radius: 3px;
background-color: rgba(0, 0, 0, 0.47);
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.34);
text-shadow: 0 2px 5px rgba(0, 0, 0, .5);
font-weight: 400;
line-height: 1.5;
text-align: center;
color: rgba(255, 255, 255, 0.47);
}
Change your mark up to a list, makes it very easy to do this.
<ul class="center pages clearfix">
<li><buuton class="center page-number">1</buuton></li>
<li><buuton class="center page-number">2</buuton></li>
<li><buuton class="center page-number">3</buuton></li>
</ul>
Use this css
ul{
list-style:none;
}
li{
display:inline-block;
}
Related
When I change the container to be the class button1, I see the area around the button becoming orange, when I change that class to be send-message-button, it does not become green but rather white. I can add style to send-message-button if I do it within the html file but I am not sure as to why I can't do it using my styles.css file. Additionally, when I type class=", button1 shows up but not send-message-button.
.empty-text {
color: #777;
font-size: 1.5rem;
text-align: center;
}
.sent-message {
background-color: #15c6f7;
border-radius: 30px;
padding: 10px 25px;
width: 25%;
float: right;
}
.received-message {
background-color: rgb(201, 206, 208);
color: rgb(90, 124, 92);
border-radius: 30px;
padding: 10px 25px;
width: 25%;
float: left;
}
.send-message-button {
background-color: #2ce168;
border-color: #2ce168;
color: white
}
.button1 {
background-color: #e1862c;
border-color: #e1862c;
color: white
}
.card-infoDisplay {
background-color: #e1862c;
border-color: #e1862c;
}
.real-name {
background-color: rgb(255, 255, 255);
color: rgb(0, 0, 0);
}
.user-major {
background-color: rgb(255, 255, 255);
color: rgb(0, 0, 0);
}
.titleDiv {
height: 1rem;
background-color: rgba(500, 0, 0, .1);
border: solid rgba(0, 0, 0, .15);
border-width: 1px 0;
box-shadow: inset 0 .5em 1.5em rgba(0, 0, 0, .1), inset 0 .125em .5em rgba(0, 0, 0, .15);
margin-top: 20px;
margin-bottom: 10px;
}
.sectionDiv {
height: 0.25rem;
background-color: rgba(500, 0, 0, .1);
border: solid rgba(0, 0, 0, .15);
border-width: 1px 0;
box-shadow: inset 0 .5em 1.5em rgba(0, 0, 0, .1), inset 0 .125em .5em rgba(0, 0, 0, .15);
margin-top: 20px;
margin-bottom: 20px;
}
.searchDiv {
display: flex;
justify-content: center;
padding-bottom: 20px;
gap: 20px;
}
<div class="send-message-button">
<button class="btn btn-light" type="submit">Send Message</button>
</div>
Is this what you want it to look like?
.empty-text {
color: #777;
font-size: 1.5rem;
text-align: center;
}
.sent-message {
background-color: #15c6f7;
border-radius: 30px;
padding: 10px 25px;
width: 25%;
float: right;
}
.received-message {
background-color: rgb(201, 206, 208);
color: rgb(90, 124, 92);
border-radius: 30px;
padding: 10px 25px;
width: 25%;
float: left;
}
.send-message-button {
color: white
}
.btn.btn-light {
background-color: #2ce168;
border-color: #2ce168;
}
.button1 {
background-color: #e1862c;
border-color: #e1862c;
color: white
}
.card-infoDisplay {
background-color: #e1862c;
border-color: #e1862c;
}
.real-name {
background-color: rgb(255, 255, 255);
color: rgb(0, 0, 0);
}
.user-major {
background-color: rgb(255, 255, 255);
color: rgb(0, 0, 0);
}
.titleDiv {
height: 1rem;
background-color: rgba(500, 0, 0, .1);
border: solid rgba(0, 0, 0, .15);
border-width: 1px 0;
box-shadow: inset 0 .5em 1.5em rgba(0, 0, 0, .1), inset 0 .125em .5em rgba(0, 0, 0, .15);
margin-top: 20px;
margin-bottom: 10px;
}
.sectionDiv {
height: 0.25rem;
background-color: rgba(500, 0, 0, .1);
border: solid rgba(0, 0, 0, .15);
border-width: 1px 0;
box-shadow: inset 0 .5em 1.5em rgba(0, 0, 0, .1), inset 0 .125em .5em rgba(0, 0, 0, .15);
margin-top: 20px;
margin-bottom: 20px;
}
.searchDiv {
display: flex;
justify-content: center;
padding-bottom: 20px;
gap: 20px;
}
<div class="send-message-button">
<button class="btn btn-light" type="submit">Send Message</button>
</div>
I designed this button in Figma but when I copy the CSS properties from the inspect section from Figma I won't get the same output, what I'm doing wrong here?
Figma file: https://www.figma.com/file/r3z3qwUsYGsn9SVDefWVoM/problem?node-id=2%3A6
div {
display: flex;
justify-content: center;
align-items: left;
height: 100%;
text-align: center;
}
button {
width: 300px;
height: 64px;
border: none;
line-height: 23px;
text-align: center;
letter-spacing: 0.666667px;
color: #000000;
font-weight: 400;
font-size: 16px;
background: linear-gradient(135.37deg, rgba(0, 0, 0, 0.35) 4.29%, rgba(255, 255, 255, 0.35) 95.6%);
background-blend-mode: soft-light;
box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.15), -5px -5px 10px #FAFBFF, 5px 5px 10px rgba(190, 106, 255, 0.3);
border-radius: 20px;
}
<div>
<button>Wednesday</button>
</div>
I want the button to be like that
and this is what i'm getting right now
Unfortunately, button shadows won't show through the button's body, even if the body is transparent. You will have to find another way to render a very rich button like that.
See my proof of concept below.
You can also find a detailed explanation at https://stackoverflow.com/a/9573440/46915
body {
background: #777;
}
div {
display: flex;
justify-content: center;
align-items: left;
height: 100%;
text-align: center;
}
button {
position: absolute;
width: 300px;
height: 64px;
background-color: transparent;
background-repeat: no-repeat;
border: none !important;
/*background: linear-gradient(135.37deg, rgba(0, 0, 0, 0.35) 4.29%, rgba(255, 255, 255, 0.35) 95.6%);*/
background-blend-mode: soft-light;
box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.15), -5px -5px 10px #FAFBFF, 5px 5px 10px rgba(190, 106, 255, 0.3);
border-radius: 20px;
}
<div>
<button>Wednesday</button>
</div>
Basically I have a div that when hovering on it, the text moves to the right. I would like to achieve some effect as if the text were lost inside the div while moving to the right.
.rectangulo_categoria {
border-radius: 34px;
border: 2px solid red;
width: 195px;
height: 50px;
display: flex;
justify-content: center;
align-items: center;
-webkit-box-shadow: 10px 10px 5px 0px rgba(0, 0, 0, 0.75);
-moz-box-shadow: 10px 10px 5px 0px rgba(0, 0, 0, 0.75);
box-shadow: 8px 4px 10px -1px rgba(0, 0, 0, 0.75);
}
.rectangulo_categoria:hover .texto_engranen_1 {
transform: translate(168px, 0px);
opacity: 0;
}
.texto_engranen_1 {
line-height: 1;
pointer-events: none;
z-index: 1;
font-size: 12px;
width: auto;
font-weight: 400;
pointer-events: none;
line-height: 1;
transition: 0.5s all ease-out;
opacity: 1;
color: #343434;
}
<div class="rectangulo_categoria" mdbWavesEffect>
<p class="texto_engranen_1 p-0 m-0">Gestion Recursos de Apoyo Académico</p>
</div>
this is my full code:
https://jsfiddle.net/te0p2fqb/
You can add a overflow: hidden; on the div. Also I re-arranged your classes and removed some duplicate props.
.rectangulo_categoria {
border-radius: 34px;
border: 2px solid red;
width: 195px;
height: 50px;
display: flex;
justify-content: center;
align-items: center;
-webkit-box-shadow: 10px 10px 5px 0px rgba(0, 0, 0, 0.75);
-moz-box-shadow: 10px 10px 5px 0px rgba(0, 0, 0, 0.75);
box-shadow: 8px 4px 10px -1px rgba(0, 0, 0, 0.75);
overflow: hidden;
}
.texto_engranen_1 {
line-height: 1;
z-index: 1;
font-size: 12px;
width: auto;
font-weight: 400;
pointer-events: none;
transition: 0.5s all ease-out;
opacity: 1;
color: #343434;
}
.rectangulo_categoria:hover .texto_engranen_1 {
transform: translate(168px, -50%);
opacity: 0;
}
<div class="rectangulo_categoria" mdbWavesEffect>
<p class="texto_engranen_1 p-0 m-0">Gestion Recursos de Apoyo Académico</p>
</div>
EDIT
Sure check the code on fiddle for aboslute solution. The main changes are that I removed the flex and its attributes, also reset the margin and padding on the <p>.
add overflow: hidden; to your .rectangulo_categoria class
.rectangulo_categoria{
border-radius: 34px;
border: 2px solid red;
width: 195px;
height: 50px;
display: flex;
justify-content: center;
align-items:center;
-webkit-box-shadow: 10px 10px 5px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 10px 10px 5px 0px rgba(0,0,0,0.75);
box-shadow: 8px 4px 10px -1px rgba(0, 0, 0, 0.75);
overflow: hidden; // this is your solution
}
I need to create this button with CSS only and have an issue with box shadow. There are two different shadows on this button: one yellow, one black. The maximum what I get is this
.button {
height: 81px;
width: 250px;
text-align: center;
font-family: 'Celias_Medium', 'Open Sans:500', sans-serif;
font-size: 11px;
line-height: 3.3;
letter-spacing: 0.4px;
cursor: pointer;
outline: none;
display: block;
vertical-align: top;
padding: 23px 0 26px 0;
text-transform: uppercase;
color: #000000;
background-color: #fbfb5c;
box-shadow: 0 20px 90px -30px rgba(251, 251, 92, 0.9), 0 40px 90px -50px rgba(0, 0, 0, 0.5)
}
<div class="button">ADD 7 Activities</div>
Here is result. Is there any other solution to get this result?
try on this if u cant see it on chrome moz or safari
.button {
height: 81px;
width: 250px;
text-align: center;
font-family: 'Celias_Medium', 'Open Sans:500', sans-serif;
font-size: 11px;
line-height: 3.3;
letter-spacing: 0.4px;
cursor: pointer;
outline: none;
display: block;
vertical-align: top;
padding: 23px 0 26px 0;
text-transform: uppercase;
color: #000000;
background-color: #fbfb5c;
box-shadow: 0 20px 90px -30px rgba(251, 251, 92, 0.9), 0 40px 90px -50px rgba(0, 0, 0, 0.5);
-moz-box-shadow: 0 20px 90px -30px rgba(251, 251, 92, 0.9), 0 40px 90px -50px rgba(0, 0, 0, 0.5);
-webkit-box-shadow: 0 20px 90px -30px rgba(251, 251, 92, 0.9), 0 40px 90px -50px rgba(0, 0, 0, 0.5);
}
hope this one works :)
Is that what you want?
.button {
height: 81px;
width: 250px;
text-align: center;
font-family: 'Celias_Medium', 'Open Sans:500', sans-serif;
font-size: 11px;
line-height: 3.3;
letter-spacing: 0.4px;
cursor: pointer;
outline: none;
display: block;
vertical-align: top;
padding: 23px 0 26px 0;
box-sizing: border-box;
text-transform: uppercase;
color: #000000;
background-color: #fbfb5c;
box-shadow: 1px 1px 70px -24px;
}
<div class="button">
ADD y activities
</div>
Generally speaking material buttons would look something like this, but I don't really know what you're asking.
.button {
height: 81px;
width: 250px;
text-align: center;
font-family: Celias_Medium, 'Open Sans:500', sans-serif;
font-size: 11px;
line-height: 3.3;
letter-spacing: .4px;
cursor: pointer;
vertical-align: top;
padding: 23px 0 26px;
box-sizing: border-box;
text-transform: uppercase;
background-color: #fbfb5c;
border-radius: 4px;
margin: 16px 0;
box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 1px 2px rgba(0, 0, 0, .24);
transition: all .3s cubic-bezier(.25, .8, .25, 1)
}
.button:hover {
box-shadow: 0 14px 28px rgba(0, 0, 0, .25), 0 10px 10px rgba(0, 0, 0, .22)
}
<div class="button">
Button no. 1
</div>
<div class="button">
Button no. 2
</div>
<div class="button">
Button no. 3
</div>
<div class="button">
Button no. 4
</div>
<div class="button">
Button no. 5
</div>
Who could help me to vertically align 2 divs inside a button element with these properties :
height of button is known
height of orange div is unknown
one of the div contain text (orange div), with 1 or 2 lines (number of lines is unknown)
.
Here is html code :
<button style="width: calc(125px * 1); height: calc(30px + 24px); margin-top: 0;margin-bottom: 0;">
<div id='bt_icon'></div>
<div id='bt_text'>Fermer</div>
</button>
CSS :
button {
display: inline-block;
border: 1px solid rgba(0, 0, 0, 0.5);
border-radius: 3px;
padding-left: 5px;
padding-right: 5px;
color: black;
font-family:'Tahoma', 'Arial', 'Helvetica', sans-serif;
font-size: 13px;
cursor: pointer;
background: linear-gradient(to bottom right, #EDDDB5, #D5C59D);
box-shadow: 2px 2px 0 rgba(255, 255, 255, 0.3) inset, -1px -1px 0 rgba(0, 0, 0, 0.3) inset, 2px 2px 8px rgba(0, 0, 0, 0.3);
}
#bt_icon {
float: left;
width: 34px;
height: 34px;
background-color: green;
}
#bt_text {
float: right;
width: calc(100% - 10px - 34px);
background-color: orange;
}
And the fiddle :
https://jsfiddle.net/15xceg8p/1/
The green square will contain an icon and is well vertically centered. The orange rectangle will contain text and is not vertically centered :(
Please update code
button {
display: inline-block;
border: 1px solid rgba(0, 0, 0, 0.5);
border-radius: 3px;
padding-left: 5px;
padding-right: 5px;
color: black;
font-family:'Tahoma', 'Arial', 'Helvetica', sans-serif;
font-size: 13px;
cursor: pointer;
background: linear-gradient(to bottom right, #EDDDB5, #D5C59D);
box-shadow: 2px 2px 0 rgba(255, 255, 255, 0.3) inset, -1px -1px 0 rgba(0, 0, 0, 0.3) inset, 2px 2px 8px rgba(0, 0, 0, 0.3);
}
#bt_icon {
width: 34px;
height: 34px;
background-color: green;
display: inline-block;
vertical-align: middle;
}
#bt_text {
display: inline-block;
vertical-align: middle;
width: calc(100% - 10px - 34px);
background-color: orange;
}
<button style="width: calc(125px * 1); height: calc(30px + 24px); margin-top: 0;margin-bottom: 0;">
<div id='bt_icon'></div>
<div id='bt_text'>Fermer</div>
</button>
try below styles and remove all css style from button
button{display: table-cell;}
button>div{display: table-cell;vertical-align: middle;}
Also remove float from both div's.
https://jsfiddle.net/t698pL8j/