Underline several lines of text + underline to be full width + responsive - css

I have a heading. On a desktop screen the heading is three lines, on a phone screen it is six lines.
The text is left aligned (not justified).
I want all lines of text to be 'underlined' and the line to be 100% of the width of the containing div (not the width of the text).
The line height is measured in ems. And at smaller break-points the font size is measured in vw.
I've tried created a repeating background-image linear-gradient, but because the line-height is measured in ems and I only want the underline to be 1px heigh, browsers are calculating the height of the underline to be less than 1px (see second image showing a border-top of 1px compared to the linear-gradient - both are rgb(255,255,255). Hence the underlines look very faint. And at smaller viewports are very hard to see.
Any suggestions?
html {
font-size: 62.5%;
}
.hero_image {
color: rgb(255, 255, 255);
background-color: rgb(0, 0, 0);
padding-bottom: 8rem;
max-width: 111.6rem;
}
.hero_image h1 {
font-size: 12rem;
line-height: 1.1em;
background-image: linear-gradient(to bottom, rgb(0, 0, 0) calc(1.1em - 1px), rgb(0, 220, 200) 1.1em);
background-repeat: repeat-y;
background-size: 100% 1.1em;
}
#media screen and (max-width:660px) {
html {
font-size: 56%;
}
.hero_image h1 {
font-size: 10vw;
}
}
<div class="hero_image">
<h1>XYZXYZ <br>fancy design agency for posh stuff</h1>
</div>
https://jsfiddle.net/4exgf7zs/1/
POSSIBLE SOLUTION
By adding in a third stop on the linear gradient it now seems to work. And increasing the line to 2px. Although I don't understand why?
background-image: linear-gradient(to bottom, black calc(1.1em - 2px), white calc(1.1em - 2px), white 1.1em);

While I couldn't exactly explain why this issue occurs, it can be avoided using repeating-linear-gradient over the whole element instead of a linear-gradient which gets tiled.
html {
font-size: 62.5%;
}
.hero_image {
color: rgb(255, 255, 255);
background-color: rgb(0, 0, 0);
padding-bottom: 8rem;
max-width: 111.6rem;
}
.hero_image h1 {
font-size: 12rem;
line-height: 1.1em;
background-image: repeating-linear-gradient(
to bottom,
rgb(0, 0, 0),
rgb(0, 0, 0) calc(1.1em - 1px),
rgb(0, 220, 200) calc(1.1em - 1px),
rgb(0, 220, 200) 1.1em
);
}
#media screen and (max-width:660px) {
html {
font-size: 56%;
}
.hero_image h1 {
font-size: 10vw;
}
}
<div class="hero_image">
<h1>XYZXYZ <br>fancy design agency for posh stuff</h1>
</div>
This solution seems to be causing some issues where a line may or may not appear below the last line, you might want to fiddle some more with it.

Related

Change the background color of a menu to show active page using SASS and twig

Ok, so my question's relatively simple and I'm certain I'm super close to solving it, but I just can't see the solution. I'm developping a website using October CMS and I'm using SASS to deal with my various CSS styles. What I'm trying to do here is basically have a menu visually show me on what page by altering the background color. Here's what I have in my SCSS file:
.left-menu{
height: 30px;
width: 186px;
letter-spacing: 1px;
font-size: 18px;
font-weight: 300;
color: white;
line-height: 30px;
text-align: center;
.normal {
background: #f47321;
background: linear-gradient(135deg, transparent 21px, #f47321 0);
}
.active {
background: #f68b1f;
background: linear-gradient(135deg, transparent 21px, #f68b1f 0);
}
&:hover{
background: #f68b1f;
background: linear-gradient(135deg, transparent 21px, #f68b1f 0);
}
}
And on my web page, I have the following:
<div class="{{ (page == 'accueil') ? 'left-menu active' : 'left-menu normal' }} ">ACCUEIL</div>
I'd like to point out that the twig condition works and, when I'm on the "accueil" page, I end up having the "left-menu active" part displayed in the class attribute and the "left-menu normal" class when I'm on another page.
My problem is that it doesn't work. For some reason, the "active" and "normal" parts don't get picked up. However, the "hover" works perfectly. Anyone has any idea what I'm doing wrong?
EDIT: In response to joknawe, I did the following modifications to my code (adding the ampersand and getting rid of the "normal" style):
.left-menu{
height: 30px;
width: 186px;
letter-spacing: 1px;
font-size: 18px;
font-weight: 300;
color: white;
line-height: 30px;
text-align: center;
background: #f47321;
background: linear-gradient(135deg, transparent 21px, #f47321 0);
&.active {
background: #f68b1f;
background: linear-gradient(135deg, transparent 21px, #f68b1f 0);
}
&:hover{
background: #f68b1f;
background: linear-gradient(135deg, transparent 21px, #f68b1f 0);
}
}
This gets compiled to the following:
.left-menu {
height: 30px;
width: 186px;
letter-spacing: 1px;
font-size: 18px;
font-weight: 300;
color: white;
line-height: 30px;
text-align: center;
background: #f47321;
background: linear-gradient(135deg, transparent 21px, #f47321 0);
}
.left-menu.active  {
background: #f68b1f;
background: linear-gradient(135deg, transparent 21px, #f68b1f 0);
}
Then, in the html page, I have the resulting code:
<div class="left-menu active ">ACCUEIL</div>
However, it still doesn't work. All I have is the standard background, the "active" class doesn't seem to get picked up by the browser.
You will need to add & to those selectors: &.normal and &.active (similar to &:hover)
Your current use is treating .normal and .active as children (applying to any child element of .left-menu that has those classes) when you are actually looking for the element to have both the .left-menu and .normal (or .active) classes.
https://css-tricks.com/the-sass-ampersand/
Side note:
You could probably do away with the .normal class and just add those styles directly to .left-nav since background will be overridden with &.active and &:hover.
You could also combine those 2 selectors if the styles will be the same:
&.active, &:hover {
background: #f68b1f;
background: linear-gradient(135deg, transparent 21px, #f68b1f 0);
}
Finally, I'd probably suggest moving those styles to be applied to the <a> (vs. having a child <div>) if possible.

Button with 2 colors as a border

I'm trying to create a button that has two colors as a border.
The two colors i need used are blue: #00a7e1, orange: #f6531d.
I would like to just use css if possible.
Thank in advance!
link to button concept
Example:
.btn
{
border: 0;
padding: 4px;
display: inline-block;
background: linear-gradient(20deg, #00a7e1 49%, #e65300 50%);
}
.bg
{
background: #349645;
padding: 8px 14px;
font: bold 24px Consolas;
}
.btn:active .bg
{
background: #0a1117;
color: #ffffff;
}
<div class="btn"><div class="bg">YOU'R TITLE</div></div>
<button class="btn"><div class="bg">YOU'R TITLE</div></div>
You may also play with gradient and background-clip (see comments in CSS)
button {
vertical-align: top;
border: 5px solid transparent;/* give extra space for gradients colors */
font-size: 2.5rem;
margin: 0.25em;
padding: 0.5em 2em;
background: linear-gradient(#333, #333),/* black turned into gradient to hold with background-clip and hide the 2 color gradient under it */
linear-gradient(/* 2 colors to draw under the borders also via background-clip*/
to bottom left,
rgb(230, 83, 0) 50%,
gray 51%,
rgb(0, 166, 224) 40%
)
no-repeat center center;
background-clip:
padding-box, /* drawn inside including padding area */
border-box;/* drawn also under borders */
background-size:
100% 100%,
110% 150%;/* must be bigger than 100% so it include also borders, else it repeats */
color: white;
box-shadow: 0 0 2px 2px black, inset 0 0 2px black;/* did you want this too ? */
}
<button>BUTTON</button> <button> TO</button> <button> PLAY</button>
If you think this is too much, you also have border-image .
Simply use border-image with a gradient:
button {
padding:20px;
border:5px solid;
border-image:linear-gradient(60deg,#00a7e1 50%,#f6531d 0) 20;
background:transparent;
}
<button>some text</button>

Is there any way to design the font color of the last row of text?

I want the styles as follow image:
expectation omission style
The styles and relative code that I made as follows: image: https://gyazo.com/171b8cf4785c2c0e629828982ac4cb69
relative code:
.msg-content
position: relative
#media(max-width: 767px)
display: block
padding-top: 10px
padding-bottom: 10px
#media(min-width: 768px)
&:after
position: absolute
height: 100px
content: ""
top: 0px
left: 0px
right: 0px
bottom: 0px
background: -webkit-linear-gradient(bottom, #FFFFFF 48px, rgba(255, 255, 255, 0.6) 48px, rgba(255, 255, 255,0.6) 58px, rgba(255, 255, 255, 0) 58px)
There are the :last-child and :last-of-type pseudo-classes. Adapted to your example:
div > p:last-child { color:#c5c5c5; }
or
div > p:last-of-type { color:#c5c5c5; }
However, this solution presupposes that you split the text into lines beforehand ( at least the final line ). It appears that you are actually after a css pseudo-element in the vein of ::first-line that would apply styles to the last line of an element. Unfortunately, afaik, no such beast exists.
your html:-
<div>
<p>Something your text........</p>
<p>Something your text........</p>
<p class="special">Something your text........</p>
</div>
your css:-
p {
color:#000;
}
p.special{
color:#c5c5c5;
}
If you want to different color same line then you can use <span></span>.
html:-
<div>
<p>hello<span>world</span></p>
</div>
css:-
p{
color:black;
}
span{
color:red;
}

What is the purpose of noise images blended into a CSS button?

I noticed that the buttons on unfuddle.com use a layer of noise, i was just wondering what the purpose of this is, i can't visibly notice the difference, but perhaps this is some cross browser hack?
It seems silly to build such an awesome CSS3 button that uses no images only to still load a noise image anyway.
Here is their CSS that goes with the buttons in question, note the gnoise.png?cbv-1346878364
.gp_button, a.gp_button, input.gp_button:not([type="radio"]) {
background-color: #C0EB00;
background-image: radial-gradient(at center center , #7EBD00 20%, #77B300 80%), url("/images/gnoise.png?cbv=1346878364");
border-color: #7FBF00;
border-radius: 4px 4px 4px 4px;
border-style: solid;
border-width: 1px;
box-shadow: 0 2px 0 rgba(0, 0, 0, 0.1);
color: #FFFFFF;
display: inline-block;
font-family: "Lato","Arial",sans-serif;
font-size: 20px;
font-weight: 700;
letter-spacing: 1px;
line-height: 34px;
margin-right: 1px;
padding: 0 1em;
text-decoration: none;
text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1);
}
.gp_button:hover, a.gp_button:hover, input.gp_button:hover:not([type="radio"]) {
background-color: #A5C416;
background-image: radial-gradient(at center center , #85C700 20%, #7EBD00 80%), url("/images/gnoise.png?cbv=1346878364");
border-color: #7FBF00;
}
.gp_button:visited, a.gp_button:visited, input.gp_button:visited:not([type="radio"]) {
background-color: #C0EB00;
background-image: radial-gradient(at center center , #7EBD00 20%, #77B300 80%), url("/images/gnoise.png?cbv=1346878364");
border-color: #7FBF00;
}
.gp_button:active, a.gp_button:active, input.gp_button:active:not([type="radio"]) {
background-color: #C0EB00;
background-image: radial-gradient(at center center , #7EBD00 20%, #77B300 80%), url("/images/gnoise.png?cbv=1346878364");
border-color: #90D900;
box-shadow: 0 0 0 rgba(0, 0, 0, 0.1);
}
.oldie .gp_button, .oldie a.gp_button, .oldie input.gp_button:not([type="radio"]) {
background-color: #7EBD00;
border-color: #7FBF00;
border-radius: 4px 4px 4px 4px;
border-style: solid;
border-width: 1px;
box-shadow: 0 2px 0 rgba(0, 0, 0, 0.1);
color: #FFFFFF;
display: inline-block;
font-family: "Lato","Arial",sans-serif;
font-size: 20px;
font-weight: 700;
letter-spacing: 1px;
line-height: 34px;
margin-right: 1px;
padding: 0 1em;
text-decoration: none;
text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1);
}
.oldie .gp_button:hover, .oldie a.gp_button:hover, .oldie input.gp_button:hover:not([type="radio"]) {
background-color: #85C700;
}
.oldie .gp_button:visited, .oldie a.gp_button:visited, .oldie input.gp_button:visited:not([type="radio"]) {
background-color: #7EBD00;
}
.oldie .gp_button:active, .oldie a.gp_button:active, .oldie input.gp_button:active:not([type="radio"]) {
background-color: #7EBD00;
border-color: #90D900;
}
gnoise.png goes on top of the background-color (along with the radial gradient) to add some visual complexity to an otherwise flat image. The effect is barely visible on a.gp_button, but you can see it if you zoom in on a screenshot using Photoshop, or use the eyedropper to compare pixel colors. The effect is more visible on the <footer> element, because of its darker background color.
By re-using one image on top of solid colors, they get a variety of colors while avoiding multiple HTTP requests which might slow down page loading.
It's just a guess, but the get parameter (?cbv=1346878364) could be used to ensure that, after an update to the image files, a new image file is actually pulled from the server instead of using a browser-cached version.
My guess is that it could have been there for browsers that don't support CSS3. However when I inspect the button in chrome it is overwritten by another image, which makes me believe that is not the case.
If it is not there for older browsers then chances are it is just a coding error. maybe they used it at some point and forgot to take it out.
But to answer your question. It isn't used for anything because it is been overwritten by this image. And if you are looking to replicate what they are doing then I would just remove it.
background-image: -webkit-radial-gradient(center center, #7ebd00 20%,#77b300 80%),url('/images/gnoise.png?cbv=1346878364');

Button shine/glow with CSS3

I have a navigation menu that I'm trying to recreate using only CSS3 and HTML. The design calls for a shine/glow on the currently selected menu button as per the "home" button on the attached pic. Is that effect possible using just code or will I need to use the glow image?!
Notice the shine and white line is most visible towards the center of the button and then fades towards the edges.
CSS3's radial gradients let you achieve a similar effect, although using a CSS background image may be easier for pixel-perfect adjustments. Specifically, CSS3's gradients are linear, even the radial ones.
I've constructed a small example using Firefox's radial gradients (support for Webkit will require quite different code): http://jsfiddle.net/rxMf6/
HTML:
<div class="highlighted-button">
<div class="highlight"></div>
Button
</div>
CSS:
.highlighted-button {
background: #000;
color: #fff;
font: bold 0.8em Arial, sans-serif;
padding-bottom: 0.9em;
text-align: center;
text-transform: uppercase;
width: 8em;
}
.highlight {
background: -moz-radial-gradient(center top, ellipse farthest-side,
#fff 0%, #000 100%);
height: 0.5em;
margin-bottom: 0.4em;
}
yes,that's shine is possible in css3.You adjust gradient as per your requirement.you us filter for IE.
i hope this example help's you.
.menu {
float: left;
margin: 10px 10px 10px 0;
background: #000;
width: 700px;
}
.menu ul {
margin: 15px 0 15px 5px;
}
.menu ul li {
display: inline;
list-style: none;
font-size: 12px;
font-family: arial;
color: #fff;
font-weight: normal;
}
.menu ul li:before {
display: inline;
content: "/";
}
.menu ul li:first-child:before {
content: " ";
height:45px;
}
.menu ul li a {
margin: 0 15px 0 15px;
color: #fff;
text-decoration: none;
padding:17px 30px 16px 30px;;
}
.menu ul li a:hover {
border-top:1px solid rgba(255, 255, 255, 0.4);
text-decoration: underline;
color: #fff;
padding:17px 30px 16px 30px;
background: -moz-radial-gradient(center -5px 45deg, ellipse farthest-corner, rgb(255, 255, 255)0%, rgba(0, 0, 0, 0.2)70%) repeat #000;
background: -webkit-gradient(radial, 50% 0, 0, 50% 0,50, from(rgba(255, 255, 255, 0.9)), to(#000));
}
<nav>
<div class="menu">
<ul>
<li>HOME</li>
<li>WHAT IS THIS?</li>
<li>SWEAR DICTIONARY</li>
</ul>
</div>
</nav>
Here is a similar CSS3 gradient. You can change the colors and get your desired look. I don't know if it is exactly like what you wanted though. It doesn't do a rounded look just a straight gradient.
background-image: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0.32, rgb(14,15,14)),
color-stop(0.7, rgb(0,0,0)),
color-stop(0.85, rgb(201,201,201))
);
background-image: -moz-linear-gradient(
center bottom,
rgb(14,15,14) 32%,
rgb(0,0,0) 70%,
rgb(201,201,201) 85%
);
You will need an image. There is really no way to achieve this effect with just code. Though most browsers can be handled with the use of CSS3 box-shadow or gradients, Internet Explorer 8, and partially IE 9 will have issues. To give proper cross-browsers support, you will have to use images to achieve the desired effect.
The reason I say you will need an image is very well may have to include additional markup and hacky workarounds to achieve the effect. This is not desirable and could cause conflicts in trying to implement the CSS3 version as well.

Resources