I'm creating a page where I have some elements and they could be hidden or not. I'd like to know if it's possible to adjust my font-size according to my div?
For example, when I have 2 elements shown, I'd like my text to be bigger than when I have 5, so this way my text would fit better the space.
My JavaScript Code, which define if the element will be hidden or not.
var val_kpi = $("#t3_teste_B_kpi").text();
var val_kpi_clean = Number(val_kpi.replace(/[^0-9.-]+/g,""));
if (val_kpi_clean != null && val_kpi_clean != 0){
$("#t3_teste_B").css("display", "");
}else{
$("#t3_teste_B").css("display", "none");
}
.tier3_test{
width:50%;
min-height: 100px;
height: auto;
margin-right: 2.5px ;
/*Configurações Visuais */
background: #FFF;
/*Configurações da Borda */
border: 5px solid;
border-image-slice: 1;
/* border-radius: 30px 30px 30px 30px; */
border-image-source: linear-gradient(to left, #2B6640, #66B512);
}
.flex-center {
display: flex;
justify-content: center;
align-items: center;
}
.tier3_in{
margin: 10px 5px 10px 5px;
width:100%;
}
.kpititle3{
font-weight: bold;
color: #000;
font-size: calc(8px + (12 - 8) * ((100vw - 300px) / (1600 - 300)));
}
.kpitext3 {
font-size: calc(10px + (16 - 10) * ((100vw - 300px) / (1600 - 300)));
font-weight: bold;
}
.no-wrap{
white-space: nowrap;
}
<div class="tier3_test flex-center">
<div class="tier3_in" id="t3_teste_A">
<span class="kpititle3">A</span>
<p><span class="kpitext3" id="t3_teste_A_kpi">VALOR 1</span></p>
</div>
<div class="tier3_in" id="t3_teste_B">
<span class="kpititle3">B</span>
<p><span class="kpitext3" id="t3_teste_B_kpi">VALOR 2</span></p>
</div>
<div class="tier3_in" id="t3_teste_C">
<span class="kpititle3">C</span>
<p><span class="kpitext3" id="t3_teste_C_kpi">VALOR 3</span></p>
</div>
<div class="tier3_in" id="t3_teste_D">
<span class="kpititle3">D</span>
<p><span class="kpitext3" id="t3_teste_D_kpi">VALOR 4</span></p>
</div>
<div class="tier3_in" id="t3_teste_E">
<span class="kpititle3">E</span>
<p><span class="kpitext3" id="t3_teste_E_kpi">VALOR 5</span></p>
</div>
</div>
The Result I Have:
The Result I'd like to have:
There is no way to do this using simple CSS.
Chris Coyier over at CSS-Tricks explains the best solutions, and all use javascript. However, there is no point figuring it out yourself - Coyier discusses a few already-written libraries that do the job for you.
Below is an example using your code and the first such library: Dave Rupert’s FitText library. Click the button to see what happens when three divs are removed.
jsFiddle Demo (StackSnippets not working at the moment)
var grow_factor = $('.tier3_in').length / 2;
$('.tier3_test').fitText( grow_factor );
/* Below is just to remove divs for demo... */
$('button').click(function(){
$('#t3_teste_C, #t3_teste_D, #t3_teste_E').remove();
var grow_factor = $('.tier3_in').length / 2;
$('.tier3_test').fitText( grow_factor );
});
.tier3_test{
width:50%;
min-height: 100px;
height: auto;
margin-right: 2.5px ;
/*Configurações Visuais */
background: #FFF;
/*Configurações da Borda */
border: 5px solid;
border-image-slice: 1;
/* border-radius: 30px 30px 30px 30px; */
border-image-source: linear-gradient(to left, #2B6640, #66B512);
}
.flex-center {
display: flex;
justify-content: center;
align-items: center;
}
.tier3_in{
margin: 10px 5px 10px 5px;
width:100%;
}
.kpititle3{
font-weight: bold;
color: #000;
}
.no-wrap{
white-space: nowrap;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/jquery.fittext.js"></script>
<div class="tier3_test flex-center">
<div class="tier3_in" id="t3_teste_A">
<span class="kpititle3">A</span>
<p><span class="kpitext3" id="t3_teste_A_kpi">VALOR 1</span></p>
</div>
<div class="tier3_in" id="t3_teste_B">
<span class="kpititle3">B</span>
<p><span class="kpitext3" id="t3_teste_B_kpi">VALOR 2</span></p>
</div>
<div class="tier3_in" id="t3_teste_C">
<span class="kpititle3">C</span>
<p><span class="kpitext3" id="t3_teste_C_kpi">VALOR 3</span></p>
</div>
<div class="tier3_in" id="t3_teste_D">
<span class="kpititle3">D</span>
<p><span class="kpitext3" id="t3_teste_D_kpi">VALOR 4</span></p>
</div>
<div class="tier3_in" id="t3_teste_E">
<span class="kpititle3">E</span>
<p><span class="kpitext3" id="t3_teste_E_kpi">VALOR 5</span></p>
</div>
</div>
<button>Remove 3 Divs</button>
In your javascript, simply add / remove one of two extra-classes (.big-font and .small-font)to your wrapper div (.tier-3-test) in function of if its elements are removed or not. In your css, you then define a font-size for extra class 1 which is added if the wrapper div contains all 5, and another font-size for extra class 2 which is added if the wrapper div contains less divs, more or less like so:
.big-font {
font-size: 30px;
}
.small-font {
font-size: 20px;
}
so I'm a beginner and I started this project by first writing CSS in styles.scss and then transforming the code inside of it using scss tools. I made an each loop to loop through a set of colors in my color map, placed in a mixin and put that mixin under [class^=btn].
I don't know why this doesn't work?
Here is my SCSS:
//colors
$base-grey: #808080;
$base-white: #ffffff;
$base-green: #71eeb8;
$base-blue: #2dcae6; //base-success: #33c052;
$base-red: #ff6666; //red
$base-orange: #ff751a; //warning
$base-purple: #8a54f7; //info
// grid base class
.grid {
// .grid__row
&__row {
padding: 1em 10px;
display: flex;
flex-direction: column;
// NOTE: replace with media query mixin if aiming for exceeds
#media (min-width: 768px) {
flex-direction: row;
}
}
// .grid__col
&__col {
// create grid columns dynamically
// loop through each column size
#for $i from 1 through 12 {
// concatenate CSS selector, ie when $i = 1,
// selector would be .grid__col--1
&--#{$i} {
// base styles applied to all grid columns
// NOTE: could be converted to a placeholder, along with margin
// from the media query
margin-top: 10px;
flex-basis: 100%;
border: 1px red solid;
// NOTE: replace with media query mixin if aiming for exceeds
#media (min-width: 768px) {
// base stlyes applied to all grid columns
margin-top: 0;
// make column width a percentage of the column number / total columns
flex-basis: #{$i / 12 * 100 + "%"} ;
}
}
}
}
}
// targets all elements with classes that begin with grid__col
[class^=grid__col] {
// grid__col + grid__col, targets two sibling columns
& + & {
// NOTE: replace with media query mixin if aiming for exceeds
#media (min-width: 768px) {
// add grid gutter
margin-left: 10px;
}
}
}
.grid {
&__row {
display: flex;
}
}
//BASE
.container {
text-align: left;
font-family: 'Arial Narrow', Arial,sans-serif;
color: $base-grey;
padding: 5px;
font-weight: 500;
}
p {
text-align: left;
line-height: 1.3;
}
a {
text-decoration: none;
}
//NAVIGATION
.nav {
list-style-type: none;
padding: 0;
text-align: center;
}
.nav__item a {
display: block;
color: inherit;
margin: 8px 0;
padding: 8px;
}
.nav__item a:hover {
color: $base-white;
background-color: $base-green;
}
//TYPOGRAPHY
//link
.link {
color: $base-blue;
font-weight: bold;
}
//blockquote
.blockquote {
border-left: $base-green 8px solid;
padding-left: 10px;
font-style: oblique;
font-size: 1.2em;
}
// headlines
#mixin h2-font-weight {
font-weight: 100;
}
.headline--primary {
color: $base-green;
margin-left: 10px;
}
.headline--secondary {
text-align: left;
#include h2-font-weight;
}
//FORM
.form {
display: flex;
flex-direction: column;
&__input {
border: none;
border-bottom: 2px solid $base-green;
margin-bottom: 15px;
}
&__label--hidden {
display: none;
}
& .headline--secondary {
#include h2-font-weight;
}
}
//BUTTONS
#mixin button-styles {
display: block;
width: 100%;
border: none;
margin-bottom: 15px;
padding: 10px;
color: $base-white;
text-transform: uppercase;
font-weight: bold;
}
$button-colors :(
default:$base-blue,
success:$base-green,
error:$base-red,
warning:$base-orange,
info:$base-purple
);
#mixin button-colors {
#each $button, $color in $button-colors {
.btn--#{$button} {
background-color: #{$color};
}
}
}
[class*=btn] {
#include button-styles;
}
//IMAGE
#mixin center-images {
display: block;
max-width: 100%;
margin: 0 auto;
padding: 8px;
}
[class^=img] {
#include center-images;
}
.img {
&--frame {
border: 2px solid $base-grey;
}
}
This is my HTML:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Circles UI Kit</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/styles.css">
<link rel="stylesheet" href="css/normalize.css">
</head>
<!--
List of classes used
Grid:
.container
.grid__row
.grid__col--1 *NOT USED HERE
.grid__col--2 *
.grid__col--3
.grid__col--4
.grid__col--5
.grid__col--6
.grid__col--7
.grid__col--8
.grid__col--9
.grid__col--10 *
.grid__col--11 *
.grid__col--12
.card
.centered
.theme__colors
(.grid__col--1, .grid__col--2, .grid__col--10, and .grid__col--11 are not used here in the HTML but would be good to include in the Sass)
Typography:
.container
.link
.blockquote
.headline--primary
.headline--secondary
Image:
.img--logo
.img--frame
.img--avatar
Navigation:
.nav
.nav__item
Buttons:
.btn--default
.btn--success
.btn--error
.btn--warning
.btn--info
.theme__colors
Forms:
.form
.form__label--hidden
.form__input
-->
<body class="container">
<div class="grid__row">
<div class="grid__col--3">
<a class="link" href="/">
<img class="img--logo" alt="circles logo" src="images/logo.png">
</a>
</div>
<div class="grid__col--9">
<nav role="navigation">
<ul class="nav">
<li class="nav__item">Typography</li>
<li class="nav__item">Buttons</li>
<li class="nav__item">Form</li>
<li class="nav__item">Images</li>
<li class="nav__item">Grid</li>
</ul>
</nav>
</div>
</div>
<div class="grid__row">
<div class="grid__col--12">
<div class="card">
<p>This is what the navigation menu looks like when the screen is at 769px or higher. When the screen is less
than 769px,
the menu will be displayed vertically.</p>
</div>
</div>
</div>
<div class="grid__row">
<div class="grid__col--8">
<div class="card">
<h4 id="type" class="headline--secondary">Typography</h4>
<h1 class="headline--primary">Take a look at this amazing headline</h1>
<p>This is a typical paragraph for the UI Kit. Here is what a link might look like.
The
typical font family for this kit is Helvetica Neue. This kit is intended for clean and refreshing web layouts.
No jazz hands here, just the essentials to make dreams come true, with minimal clean web design. The kit comes
fully equipped with everything from full responsive media styling to buttons to form fields. <em>I enjoy using
italics as well from time to time</em>.
Fell free to create the most amazing designs ever with this kit. I truly hope you enjoy not only the kit but
this
amazing paragraph as well. :)</p>
<blockquote class="blockquote">You know what really gets me going? A really nice set of block quotes. That's
right, block quotes that say, "Hey,
I'm an article you want to read and nurture."</blockquote>
</div>
</div>
<div class="grid__col--4">
<form class="form">
<legend id="forms" class="headline--secondary">Form Elements</legend>
<img class="img--avatar" src="images/avatar.png" alt="Avatar">
<label class="form__label--hidden" for="username">Username:</label>
<input class="form__input" type="text" id="username" placeholder="Username">
<label class="form__label--hidden" for="password">Password:</label>
<input class="form__input" type="password" id="password" placeholder="Password">
<button class="btn--default theme__colors" type="submit" value="Login">Login</button>
</form>
</div>
</div>
<h4 id="images" class="headline--secondary">Images</h4>
<div class="grid__row">
<div class="grid__col--6">
<img class="img--frame" src="images/image.png" alt="sample image">
</div>
<div class="grid__col--6">
<img class="img--avatar" src="images/avatar.png" alt="Avatar">
</div>
</div>
<h4 id="buttons" class="headline--secondary">Buttons</h4>
<div class="grid__row">
<div class="grid__col--12">
<button class="btn--default theme__colors">default</button>
<button class="btn--success theme__colors">success</button>
<button class="btn--error theme__colors">error</button>
<button class="btn--warning theme__colors">warning</button>
<button class="btn--info theme__colors">info</button>
</div>
</div>
<h4 id="grid" class="headline--secondary">Grid System</h4>
<div class="grid__row">
<div class="grid__col--12 theme__colors">.grid__col--12</div>
</div>
<div class="grid__row">
<div class="grid__col--6 theme__colors">.grid__col--6</div>
<div class="grid__col--6 theme__colors">.grid__col--6</div>
</div>
<div class="grid__row">
<div class="grid__col--4 theme__colors">.grid__col--4</div>
<div class="grid__col--4 theme__colors">.grid__col--4</div>
<div class="grid__col--4 theme__colors">.grid__col--4</div>
</div>
<div class="grid__row">
<div class="grid__col--3 theme__colors">.grid__col--3</div>
<div class="grid__col--3 theme__colors">.grid__col--3</div>
<div class="grid__col--3 theme__colors">.grid__col--3</div>
<div class="grid__col--3 theme__colors">.grid__col--3</div>
</div>
<div class="grid__row">
<div class="grid__col--5 theme__colors">.grid__col--5</div>
<div class="grid__col--7 theme__colors">.grid__col--7</div>
</div>
<div class="grid__row">
<div class="grid__col--8 theme__colors">.grid__col--8</div>
<div class="grid__col--4 theme__colors">.grid__col--4</div>
</div>
<div class="grid__row">
<div class="grid__col--7 theme__colors centered">.centered .grid__col--7</div>
</div>
</body>
</html>
You are missing two things:
The mixin of button colours need to be:
#mixin button-colors {
#each $button, $color in $button-colors {
&.btn--#{$button} {
background-color: #{$color};
}
}
}
with & before .btn.
You didn't call your mixin. You need to write:
[class*=btn] {
#include button-styles();
#include button-colors();
}
I've been trying a few different things to remove the second page on this page when printing. Is there something I am doing wrong?
I've placed:
page-break-after: avoid;
page-break-inside: avoid;
On to the last element on the page, so I'm just a little confused on what I'm doing wrong here.
Any suggestions would be appericated.
See the code below...
/* Custom Hero Styles */
.subhero1 {
background: #000;
height: 400px !important;
}
#media only screen and (min-width: 0px) and (max-width: 650px) {
.subhero1 {
background: #000;
height: 250px !important;
}
.subhero__content-container {
color: #fff !important;
}
}
/* Custom Cards */
.obs__fullcardheader {
border-bottom: 0px;
margin-bottom: 0px;
padding-bottom: 0px;
font-size: 3.5vmax;
}
.obs__fullcard {
height: 400px;
width: 100%;
border: 5px solid #eee;
}
.obs__cardheader img {
max-width: 20%;
}
.obs__card {
height: 300px;
}
.fullcardwrapper {
background: #f6f6f6;
background-size: cover;
background-position: center;
padding-top: 30px;
line-height: 30px;
}
.cardwrapper {
padding: 30px;
}
.appicons img {
max-width: 160px;
}
.small__font {
font-size: 12px;
}
.obs__cardline2 {
font-size: 14px;
}
.obs__cardline1 a {
color: #000;
text-decoration: none;
cursor: pointer;
}
.obs__cardline1 a:hover {
color: #565656;
border-bottom: 1px solid #565656;
}
.obs__cardline2 a {
color: #000;
text-decoration: none;
cursor: pointer;
}
.obs__cardline2 a:hover {
color: #565656;
border-bottom: 1px solid #565656;
}
.coupon-btn-wrapper {
margin: 0 auto;
max-width: 300px;
}
.print-exclusions {
display: none;
}
#media (max-width: 650px) {
.obs__card {
width: 100%;
}
.obs__cardheader img {
max-width: 15% !important;
}
.obs__fullcardheader {
font-size: 4.5vmax;
}
.obs__couponhero-line1 {
padding-top: 20px;
}
}
#media (max-width: 1050px) {
.obs__card {
width: 100%;
height: 250px;
}
.obs__cardheader img {
max-width: 10%;
}
.cardwrapper {
padding: 0px;
margin-top: 0px;
}
.fullcardwrapper {
padding-top: 10px;
background: #fff;
}
.obs__fullcard {
border: 1px solid #eee;
}
.obs__fullcardheader {
font-size: 4.5vmax;
}
.coupon-btn-wrapper {
max-width: 280px;
}
}
.obs__couponhero-line1 {
font-size: 14px;
color: #000;
margin-bottom: 10px;
line-height: 18px;
padding-top: 30px;
}
.obs__couponhero-line2 {
font-size: 14px;
color: #000;
margin-bottom: 10px;
}
.obs__couponhero-barcode {
margin: 0 auto;
}
.obs__couponhero-line3 {
font-size: 14px;
color: #000;
margin-bottom: 10px;
margin-top: -30px;
}
.couponlinks a {
color: #fff;
background: #000;
text-decoration: none;
font-size: 14px;
padding: 15px;
}
#media print {
#page {
size: landscape
}
.obs__card {
width: 33%;
height: 250px;
}
.head-main,
.obs__cardline2,
.appicons,
.cust_service_headline,
.obs__accordion,
.coupon-btn-wrapper {
display: none;
}
.obs__fullcard {
height: 260px;
}
.cardwrapper {
margin-top: 10px;
max-width: 97.8%;
}
.obs__cardheader img {
max-width: 25%;
}
footer {
display: none;
}
.print-exclusions {
display: block;
padding-left: 14px;
margin-top: -115px;
margin-bottom: 0;
page-break-after: avoid;
page-break-inside: avoid;
}
.obs__fullcard {
width: 110%;
}
.obs-3 {
clear: none;
}
#page {
margin: 0;
}
body {
margin: 1.6cm;
}
}
<link href="https://media.offbroadwayshoes.com/css/obframe.css" rel="stylesheet"/>
<div class="frame fullcardwrapper">
<div class="obs__max1200">
<div class="obs__cards">
<div class="obs__fullcard">
<div class="obs__cardinner">
<div class="obs__fullcardheader">##offer##</div>
<div class="obs__couponhero-line1"><span class="new-line-mob">PLUS, BUY ONE, GET ONE</span> <span class="new-line-mob">50% OFF* YOUR 2ND PAIR</span>
<br /> *EXCLUSIONS APPLY</div>
<div class="obs__couponhero-line2">##tatic## · VALID THRU ##valid##</div>
<div class="obs__couponhero-barcode"> </div>
<div class="obs__couponhero-line3">##ifonline## <font style="font-weight:bold;">##onlinecode##</font></div>
<div class="obs__cardline3">
<div class="coupon-btn-wrapper">
<div class="obs-2-static couponlinks" style="text-align: center;">FIND YOUR STORE</div>
<div class="obs-2-static couponlinks" style="text-align: center;">PRINT COUPON</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="frame cardwrapper bg-split__greytowhite">
<div class="obs__max1440">
<div class="obs__cards">
<div class="obs__card">
<div class="obs__cardinner">
<div class="obs__cardheader"><img src="https://media.offbroadwayshoes.com/icons/bogo.svg" alt="" />
<br /> BOGO 50% OFF*</div>
<div class="obs__cardline1">Buy One, Get One 50%
<br /> Off Your 2ND Pair</div>
<div class="obs__cardline2"><a data-exctarget="#1">SEE DETAILS</a></div>
</div>
</div>
<div class="obs__card">
<div class="obs__cardinner">
<div class="obs__cardheader"><img src="https://media.offbroadwayshoes.com/icons/free-shipping.svg" alt="" />
<br /> FREE SHIPPING</div>
<div class="obs__cardline1">Get Free Shipping
<br /> on Orders $50 or More!</div>
<div class="obs__cardline2"><a data-exctarget="#2">SEE DETAILS</a></div>
</div>
</div>
<div class="obs__card">
<div class="obs__cardinner">
<div class="obs__cardheader"><img src="//media.offbroadwayshoes.com/icons/mobile-app.svg" alt="" />
<br /> DOWNLOAD THE APP</div>
<div class="obs__cardline1">Shopping at your finger tips! <a>Learn More</a>
<br />
<br />
</div>
</div>
</div>
</div>
</div>
</div>
<div class="frame">
<div class="obs__max1440">
<div class="obs__spacer50 obs__mob-spacer20"> </div> <span class="cust_service_headline rightsideheading">Details & Exclusions</span>
<div class="obs__spacer10"> </div>
<div class="obs__accordion js-obs__accordion">
<div class="obs__accordion__item js-obs__accordion-item">
<div class="obs__accordion-header js-obs__accordion-header">Coupon Exclusions</div>
<div class="obs__accordion-body js-obs__accordion-body">
<div class="obs__accordion-body__contents">*Limit one coupon per transaction. COUPON MAY ONLY BE USED ONCE AND MAY NOT BE MODIFIED, COPIED OR UPLOADED. Excludes Flash Sales, special promotional events. Must present coupon at time of purchase, cannot be combined with other coupons or used for the purchase of Gift Card(s) and is not redeemable for cash. Offer excluded on certain styles and brands, including but not limited to: Adidas, Asics, Bear Paw, Birkenstock, Converse, Keds, Merrell, Puma, Rainbow, Reebok, Rockport, Saucony, Sperry, Teva, Koolaburra by Ugg, Tommy Hilfiger Kids’, online Timberland & Timberland Pro, plus all Nike styles. Discount is taken before taxes. CAN BE COMBINED WITH EARNED QUALIFYING REWARDS DOLLARS BUT NOT OTHER REWARDS COUPON OFFERS. See store associate for details.</div>
</div>
</div>
<!-- end of obs__accordion item -->
<div class="obs__accordion__item js-obs__accordion-item">
<div class="obs__accordion-header js-obs__accordion-header" id="1">BOGO 50% OFF 2ND PAIR</div>
<div class="obs__accordion-body js-obs__accordion-body">
<div class="obs__accordion-body__contents">*2nd pair must be of equal or lesser value. Excludes BOGO Free styles, Flash Sales, special promotional events, accessories and certain other styles, including but not limited to adidas, Asics, Bear Paw, Birkenstock, Converse, Keds, Koolaburra by Ugg, Merrell, Puma, Rainbow, Reebok, Rockport, Saucony, Sperry, Teva, Tommy Hilfiger Kids’, online Timberland & Timberland Pro, plus all Nike styles.</div>
</div>
</div>
<!-- end of obs__accordion item -->
<div class="obs__accordion__item js-obs__accordion-item">
<div class="obs__accordion-header js-obs__accordion-header" id="2">Free Shipping</div>
<div class="obs__accordion-body js-obs__accordion-body">
<div class="obs__accordion-body__contents">Free economy shipping offer valid on orders with a subtotal over $50 after all discounts are applied. (Subtotal does not include tax or shipping fees)</div>
</div>
</div>
<!-- end of obs__accordion item -->
</div>
<!-- end of obs__accordion item -->
<!-- end of obs__accordion -->
</div>
</div>
<div class="obs__spacer50 obs__mob-spacer20"> </div>
<div class="print-exclusions">
<div class="obs-3">
<p class="obs__bold">COUPON EXCLUSIONS
<p>
<p style="font-size:8px;">*Limit one coupon per transaction. COUPON MAY ONLY BE USED ONCE AND MAY NOT BE MODIFIED, COPIED OR UPLOADED. Excludes Flash Sales, special promotional events. Must present coupon at time of purchase, cannot be combined with other coupons or used for the purchase of Gift Card(s) and is not redeemable for cash. Offer excluded on certain styles and brands, including but not limited to: Adidas, Asics, Bear Paw, Birkenstock, Converse, Keds, Merrell, Puma, Rainbow, Reebok, Rockport, Saucony, Sperry, Teva, Koolaburra by Ugg, Tommy Hilfiger Kids’, online Timberland & Timberland Pro, plus all Nike styles. Discount is taken before taxes. CAN BE COMBINED WITH EARNED QUALIFYING REWARDS DOLLARS BUT NOT OTHER REWARDS COUPON OFFERS. See store associate for details.</p>
</div>
<div class="obs-3">
<p class="obs__bold">BOGO 50% OFF 2ND PAIR
<p>
<p style="font-size:8px;">*2nd pair must be of equal or lesser value. Excludes BOGO Free styles, Flash Sales, special promotional events, accessories and certain other styles, including but not limited to adidas, Asics, Bear Paw, Birkenstock, Converse, Keds, Koolaburra by Ugg, Merrell, Puma, Rainbow, Reebok, Rockport, Saucony, Sperry, Teva, Tommy Hilfiger Kids’, online Timberland & Timberland Pro, plus all Nike styles.</p>
</div>
<div class="obs-3">
<p class="obs__bold">FREE SHIPPING
<p>
<p style="font-size:8px;">Free economy shipping offer valid on orders with a subtotal over $50 after all discounts are applied. (Subtotal does not include tax or shipping fees)</p>
</div>
</div>
I'm trying to have all images in my flex container have the same height using a 4:3 ratio, all of this being responsive.
When out of the flex container everything works well, but when put in it, it seems like it's the length of the title that dictates the width. I can't figure out why.
https://jsfiddle.net/ts8Lwp6g/
/* Just copying the guy in vid for now, trying to figure it all out hopefully it won't be too much of a bother responsive eh ffs , somethings I haven't copied, tryna do best */
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 15px;
background-color: gray;
width: 80%;
margin: auto;
}
#cccccc {
background-color: orange;
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.w {
background-color: red;
/* doesnt show hay */
display: block;
}
.views {
float: left
}
.rating {
float: right
}
.parentt {
max-width: 258px;
}
.containertt {
width: 100%;
position: relative;
padding-bottom: 75%;
/* 34.37% = 100 / (w / h) = 100 / (640 / 220) */
}
.containertt img {
width: 100%;
height: 100%;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
.figcaptionnnn {
/* background-color:red; */
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 100%
}
.figcaptionnnn a {
color: white;
text-decoration: none;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="tete.css">
</head>
<body>
<div id="cccccc">
<div class="parentt">
<div class="containertt">
<img height="145" width="258" src="https://s3-us-west-2.amazonaws.com/i.cdpn.io/221971.RajoRb.7fb2f73a-0b7d-4aa3-ac25-f0f31261cdae.png" />
</div>
<div class="figcaptionnnn">
<span class="titlee"><a href=https://pornhub.com/view_video.php?viewkey=1306454068 title="Tall french maid and batman" >Tall french maid and batman</a></span></br>
<div class="w"><span class="views"> 692818 views</span><span class="rating">75 %</span></div>
</div>
</div>
<div class="parentt">
<div class="containertt">
<img height="145" width="258" src="https://s3-us-west-2.amazonaws.com/i.cdpn.io/221971.RajoRb.7fb2f73a-0b7d-4aa3-ac25-f0f31261cdae.png" />
</div>
<div class="figcaptionnnn">
<span class="titlee"><a href=https://pornhub.com/view_video.php?viewkey=1306454068 title="Tall french maid and batman" >Tall french maid and batman vdfvdsv dvdfv ddffv dvddv dvdcffc dvdfcd</a></span><br/>
<div class="w"><span class="views"> 692818 views</span><span class="rating">75 %</span></div>
</div>
</div>
</div>
<div class="parentt">
<div class="containertt">
<img height="145" width="258" src="https://s3-us-west-2.amazonaws.com/i.cdpn.io/221971.RajoRb.7fb2f73a-0b7d-4aa3-ac25-f0f31261cdae.png" />
</div>
<div class="figcaptionnnn">
<span class="titlee"><a href=https://pornhub.com/view_video.php?viewkey=1306454068 title="Tall french maid and batan" >Tall french maid and batman</a></span></br>
<div class="w"><span class="views"> 692818 views</span><span class="rating">75 %</span></div>
</div>
</div>
<div class="parentt">
<div class="containertt">
<img height="145" width="258" src="https://s3-us-west-2.amazonaws.com/i.cdpn.io/221971.RajoRb.7fb2f73a-0b7d-4aa3-ac25-f0f31261cdae.png" />
</div>
<div class="figcaptionnnn">
<span class="titlee"><a href=https://pornhub.com/view_video.php?viewkey=1306454068 title="Tall french maid and batman" >Tall french maid and batman vdfvdsv dvdfv ddffv dvddv dvdcffc dvdfcd</a></span></br>
<div class="w"><span class="views"> 692818 views</span><span class="rating">75 %</span></div>
</div>
</div>
</body>
</html>
I am trying to achieve this layout but I'm having problems with setting a background, which should be 50% of the screen size. I thought of setting up an image as background, but there are different colors that should be different on each page.
Is it possible to achieve it using only background-color?
This is how I set the HTML, TS & CSS so far:
<div [class]="getBackground(title)">
<div class="background-header">
<img [src]="'assets/assess/Custom.png'" alt="">
{{title}}
</div>
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide" *ngFor="let theme of pillar.data; let i = index">
<button rh-btn-theme full-btn [ngClass]="{'ripple': true}" [issue]="theme" (click)="presentModal($event, theme);"></button>
</div>
</div>
</div>
</div>
TS
getBackground(pillar) {
switch (pillar) {
case "People":
return "background-people";
case "Land":
return "background-land";
case "Crop":
return "background-crop";
case "Business":
return "background-business";
default:
return "background-custom";
}
}
CSS
.background-header {
width: 100%;
height: 80%;
display: block;
position: relative;
img {
display: inherit;
background-color: #000;
}
}
.background-people {
background-color: #335F6E;
}
.background-land {
background-color: #006533;
}
.background-crop {
background-color: #7F4020;
}
.background-business {
background-color: #F8DC0B;
}
.background-custom {
background-color: map-get($colors, primary);
}
Yes you can do it by background gradient:
.content {
width: 100%;
height: 300px;
border: solid 2px #123;
background: linear-gradient( red, red 50%, white 50%, white);
}
<div class='content'></div>
Dont forget genarte cross-browser css. See about background gradient here