I tried to code the example above, but I can't still don't get it. It works with a certain length, but when the length changes (because of the content inside) it breaks and I have to manually configure the padding-bottom.
Here an example:
And here's my code:
.tjbtn, .tjbtn--orange, .tjbtn--green {
font-size: 1em;
color: #fff;
text-decoration: none;
font-weight: bold;
background-repeat: no-repeat;
background-size: 100% 100%;
background-position: center center;
padding: 1em;
line-height: 3em;
text-transform: uppercase;
letter-spacing: 2px;
background-image: url("http://tj.cadman.ws/button_bg_orange.svg");
}
Is there any possibility to code this without an attached background-image and make this fluid regardless to the width?
Thanks in advance!
Give display: inline-block; and change to background-size: 100%; will work for you.
.tjbtn, .tjbtn--orange, .tjbtn--green {
font-size: 1em;
color: #fff;
text-decoration: none;
font-weight: bold;
background-repeat: no-repeat;
background-size: 100%;
background-position: center center;
padding: 1em;
line-height: 3em;
text-transform: uppercase;
letter-spacing: 2px;
background-image: url("http://tj.cadman.ws/button_bg_orange.svg");
display: inline-block;
}
Fiddle
Related
What I'm willing to achieve is some kind of dividers that are used on http://mintteal.com/ under the captions. There is an icon inside, but I've yet failed to create such horizontal line on both sides.
You could have a peek at their HTML/CSS to learn how they did it. Here is what they have:
<div class="title">
<h1>What We Do</h1>
<i class="fi-wrench"></i>
</div>
<style>
div.title {
text-transform: uppercase;
text-align: center;
letter-spacing: 0.01em;
font-weight: 700;
position: relative;
margin-bottom: 60px;
padding-bottom: 30px;
}
.title h1 {
font-size: 48px;
margin: 0;
}
.fi-wrench::before {
content: "\f215";
font-family: "foundation-icons";
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
display: inline-block;
text-decoration: inherit;
}
div.title i {
position: absolute;
bottom: -20px;
left: 50%;
margin-left: -20px;
border: 3px solid #41c39f;
width: 40px;
height: 40px;
line-height: 37px;
background: #f4f4f5;
-webkit-border-radius: 50%;
border-radius: 50%;
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clip: padding-box;
text-align: center;
}
</style>
Perhaps this is what you wanted Demo.
The divider is made by the :before tag. And the content inside makes up the image.
Text within a button is breaking up in two lines in Safari - but not in Chrome and Firefox, see the screenshots. Using the CSS property break-word: keep-all; doesn't seem to work.
Any suggestions how to solve this?
not good:
good:
CSS code:
.button {
font-size: 1.5em;
padding: 0em 0.6em 0.1em 0.6em;
margin-left: 0%;
margin-right: 0%;
margin-bottom: 24px;
width: auto;
text-decoration:none;
display: inline-block;
border: none;
border-radius: 1em;
background-color: #4ca8da;
background-repeat: no-repeat;
font-family: 'Populaire';
font-weight: normal;
font-style: normal;
color: white;
text-align: left; }
white-space: nowrap; should fix it.
Further information.
I'm using a Raspberry Pi and Screenly-OSE as a Digital Signage solution for our pharmacy. I display various ads along with the overnights. I'm using a very simple Sinatra application to to serve overnights. Works great except from a small detail which bugs me a lot, there's a white space available there: see picture .
I'm using the following very simple css file:
body {
/* background-color: #246013; */
background-image:url('moon.jpg');
color: white;
text-align: center;
font: Verdana, Geneva, Arial, Helvetica, sans-serif;
}
#wrapper{
width:1200px;
margin:0 auto;
text-align: center;
}
#content{
text-align: center;
margin:auto;
}
#footer{
text-align: center;
padding-top: 30px;
color: #D6D6D6;
font: 14px "Courier New", Courier, mono;
}
h1 {
font-size: 80px;
padding-top: 10px;
font-weight: bold;
text-align: center;
}
h2 {
text-align: center;
font-size: 60px;
font-weight: bold;
}
h3 {
text-align: center;
font-size: 32px;
padding-top: 10px;
padding-bottom: 3px;
font-weight: bold;
}
h4 {
text-align: left;
font-size: 25px;
padding-top: 5px;
padding-bottom: 3px;
text-decoration: underline;
}
h5 {
text-align: left;
font-size: 23px;
padding-top: 5px;
padding-bottom: 3px;
font-weight: bold;
}
I wonder if there's a way to get full-screen background cover. The background picture cover goes along with the text, some days overdays are displayed and if the overdays are 5 or 6 the entire screen is covered.
I know I can simulate this behavior by adding br/ and/or counting the text lines displayed. But I wonder if there's any other other, more natural way of achieving this.
Thanks
Make sure setting both html and body to 100% height to make them cover it all.
html, body {
height: 100%;
}
I have this media query with some CSS inside, the query works fine on other sites I have used with similar CSS, and when I resize the browser I get the desired effects. But when I look on iPad or android I see no effect, it is if the media query does not exist
#media only screen and (max-width: 767px) {
.menu-button{
display: block;
height: 42px;
background-image: url(/sites/all/themes/dream/images/menu-icon.png);
background-repeat: no-repeat,repeat-x;
background-position: 98% 50%,0 0;
text-align: right;
font-weight: 700;
font-family: 'SweetSans';
text-transform: uppercase;
color: #333333;
line-height: 42px;
cursor: pointer;
padding-right: 36px;
font-size: 13px;
margin-right: 106px;
}
.menu-button {
display: block;
height: 34px;
background-image: url(/sites/all/themes/dream/images/menu-icon.png);
background-repeat: no-repeat, repeat-x;
background-position: 98% 50%, 0 0;
text-align: right;
font-weight: 700;
font-family: 'SweetSans';
text-transform: uppercase;
color: #333333;
line-height: 42px;
cursor: pointer;
padding-right: 36px;
font-size: 13px;
}
#main {
width: 100%;
}
#block-menu-primary-links ul.menu li {
float: none;
padding: 0px 0px;
width: 100%;
display: none;
float: left;
background-color: rgb(172, 173, 184);
}
#main li {
float: none;
list-style-type: none;
font-weight: 400;
}
#main li.first a {
border-left: 0px;
}
#main li a {
width: 100%;
}
#main li ul, #main li ul li, #main li ul li a {
position: relative;
float: none;
width: 100%;
}
}
You have to add the veiwport tag to your HTML (in the head):
<meta name="viewport" content="width=device-width, initial-scale=1.0">
I think that the problem is that you're placing this piece at the top:
#media only screen and (max-width: 767px) {
.menu-button{
display: block;
height: 42px;
background-image: url(/sites/all/themes/dream/images/menu-icon.png);
background-repeat: no-repeat,repeat-x;
background-position: 98% 50%,0 0;
text-align: right;
font-weight: 700;
font-family: 'SweetSans';
text-transform: uppercase;
color: #333333;
line-height: 42px;
cursor: pointer;
padding-right: 36px;
font-size: 13px;
margin-right: 106px;
}
And it's being overridden by
.menu-button {
display: block;
height: 34px;
background-image: url(/sites/all/themes/dream/images/menu-icon.png);
background-repeat: no-repeat, repeat-x;
background-position: 98% 50%, 0 0;
text-align: right;
font-weight: 700;
font-family: 'SweetSans';
text-transform: uppercase;
color: #333333;
line-height: 42px;
cursor: pointer;
padding-right: 36px;
font-size: 13px;
}
Try placing the media query and its content at the bottom.
Let me know if that worked.
Regards
I'm trying to replace the links on my app with a button background. However the link text won't center horizontally neither vertically. I'm using the property "background-position: center center;" which I assume would solve my problem.
My HTML:
<a class="violetButtonLarge" href="#">My Link</a>
CSS:
.violetButtonLarge {
display: block;
width: 304px;
height: 41px;
background: url(../images/violetButton_large.png) no-repeat center center;
border:none;
color: #FFFFFF;
font-weight: bold;
font-family: Arial;
background-color: transparent;
text-decoration: none;
}
My image:
What I'm I doing wrong here? This is what I get:
Thanks in advance!
Use text-align:center and line-height:41px to align the text in the vertical and horizontal center.
.violetButtonLarge {
display: block;
width: 304px;
height: 41px;
background: url(http://i.stack.imgur.com/S8zvb.png) no-repeat center center;
border:none;
color: #FFFFFF;
font-weight: bold;
font-family: Arial;
background-color: transparent;
text-decoration: none;
text-align:center;
line-height:41px;
}
Example: http://tinkerbin.com/q5VZR1At
a.button {
background: transparent url('violetButton_large.png') no-repeat scroll top right;
color: #FFFFFF;
display: block;
float: left;
font: normal 12px arial, sans-serif;
height: 24px;
margin-right: 6px;
padding-right: 18px;
text-decoration: none;
}
<a class="button" href="#" onclick="this.blur();"> … </a>
Probably you should set the padding, then you don't need to set the width and height. The vertical-align: baseline helps to set them on the same line with "real" input buttons.
.button {
padding: .4em 1.6em .44em 1.6em;
vertical-align: baseline;
text-align: center;
text-decoration: none;
cursor: pointer;
}
Edit: Sorry i didn't saw the image in your code, maybe you should get a glimpse at this great example: CSS Gradient Buttons.