How to apply Media Queries to Cards with Images - html

been trying to media query my cards + image, for a while now without success, if anyone can guide me through I'll appreciate it a lot thanks.
Testing it on my phone samsung s9+ vertically.
https://codepen.io/picklemyrickle/pen/XWjzyvb
#media (max-width: 600px) {
#prices {
width: 100%;
}
.listdrop {
width: 100%;
max-width: 100%;
}
.casual {
width: 100%;
}
}
#media (max-width: 600px) {
img {
max-width: 100%;
height: auto;
}
}
#prices {
display: flex;
justify-content: center;
align-items: center;
padding: 100px;
margin: 10px;
}
.listdrop {
margin: 0;
padding: 0;
-webkit-transition: 0.3s;
transition: 0.3s;
border: 1px solid;
list-style-type: none;
width: 10vw;
}
<img src="https://lh3.googleusercontent.com/JH3M2ZropJUZvOoL6IgHOrnZUz3cIEw5taJuPA2N_wyEHmr2hSBOOZHjGX05Q9wJ7DBXaQ8ABvG2rInPk7seHBVf8voG5ePyFXWY-7ciIcrpw_v7w23j6HV856fsSTKuwMpYDg1YDQ=w2400" alt="Gym logo" id="header-img">
<section id="prices">
<!-- <div class="beginner"> -->
<ul class="listdrop">
<li class="card-head">Beginner</li>
<li>Get Big</li>
<li>Get Strong</li>
<li>Feel good</li>
<li class="pay">100$</li>
<li type="button" class="butn" a href="#">Buy</a>
</button>
</li>
</ul>
<!-- </div> -->
<div class="casual">
<ul class="listdrop">
<li class="card-head">Casual</li>
<li>Get Big</li>
<li>Get Strong</li>
<li>Feel good</li>
<li class="pay">200$</li>
<li type="button" class="butn" a href="#">Buy</a>
</button>
</li>
</ul>
</div>
<!-- <div class="intermidate"> -->
<ul class="listdrop">
<li class="card-head">Intermidate</li>
<li>Get Big</li>
<li>Get Strong</li>
<li>Feel good</li>
<li class="pay">300$</li>
<li class="butn" type="button" a href="#">Buy</a>
</button>
</li>
</ul>
<!-- </div> -->
</section>
I tried changing the html, played with the CSS, without success on my own. other elements seem wide enough and works fine besides the card, I tried adding a div element as well after the section but it seems to screw my cards. With IMG I seem to be more lost, horizontally I can see the icon just much smaller, but vertically nothing, I guess because the screen isn't as wide vertically as horizontally but I'm not sure what is the solution for that.

Related

CSS display list in columns

I have a list which is made by Vue.js
Here is my code:
<ul>
<li
v-for="category in item.children"
:key="category.id"
class="menu-item"
>
<nuxt-link
:to="
localePath(
`/category/${category.slug}/${category.id}`
)
"
>
<h5>{{ category.lang[0].name }}</h5>
</nuxt-link>
<ul class="mega-menu__list">
<li
v-for="subItem in category.children"
:key="subItem.id"
>
<nuxt-link
:to="
localePath(
`/category/${subItem.slug}/${subItem.id}`
)
"
>
{{ subItem.lang[0].name }}
</nuxt-link>
</li>
</ul>
</li>
</ul>
But I want it to display like this which child is in the same column:
Any help is appreciated.
* {
font-family: "Arial";
font-size: 15px;
margin: 0;
padding: 0;
}
section {
display: flex;
flex-direction: column;
flex-wrap: wrap;
width: 450px;
height: 800px;
margin: 0 auto;
}
div {
display: flex;
flex-direction: column;
padding: 15px 30px;
}
h5 {
margin-bottom: 20px;
text-transform: uppercase;
}
ul {
list-style: none;
}
li {
line-height: 30px;
}
<section>
<div>
<h5>shop by concern</h5>
<ul>
<li>Pores</li>
<li>Whitening</li>
<li>Fine Lines & Wrinkles</li>
<li>Hydrating</li>
<li>Dark Spots</li>
<li>Anti-Aging</li>
<li>Acne & Blemishes</li>
</ul>
</div>
<div>
<h5>others</h5>
<ul>
<li>Tools & Accessories</li>
<li>Beauty Supplements</li>
</ul>
</div>
<div>
<h5>skincare package</h5>
</div>
<div>
<h5>treatment</h5>
<ul>
<li>T-Zone &vert; Blackhead</li>
<li>Ampoule</li>
<li>Acne &vert; Blemishes</li>
<li>Serum</li>
<li>Pore Care</li>
<li>Lip Care</li>
<li>Eye Care</li>
</ul>
</div>
<div>
<h5>cleanser & exfoliator</h5>
<ul>
<li>Scrub & Exfoliator</li>
<li>Face Wash & Cleansers</li>
<li>Soap</li>
</ul>
</div>
<div>
<h5>sun care</h5>
</div>
<div>
<h5>moisturizer</h5>
<ul>
<li>Mist Spray</li>
<li>Cream</li>
<li>Moisturizer / Lotion</li>
</ul>
</div>
<div>
<h5>toner</h5>
</div>
</section>
See in my example, that if you have enough height (css), a menu will try to get there, if not, it will go to the right (because it has space to go there because of flex-wrap: wrap. Play with each CSS property in section and div, and you will understand more.
You can see more about flex here. And if you want to try out grid, here.

How to break word to the next line with CSS?

How can I make it look better for mobile:
(break words by line)
I tried white-space, word-break, word-spacing, display:table-caption and can't make it work.
https://codepen.io/Jackkk/pen/zYYbvKY
.nav>li {
display: inline-block;
}
/* very simplified css*/
<ul class="nav nav-line-bottom nav-normal nav-size-normal nav-center">
<li class="tab active has-icon"><span>Meble fryzjerskie</span></li>
<li class="tab has-icon"><span>Fotele fryzjerskie</span></li>
<li class="tab has-icon"><span>Myjnie fryzjerskie</span></li>
<li class="tab has-icon"><span>Konsolety fryzjerskie</span></li>
<li class="tab has-icon"><span>Pomocniki fryzjerskie</span></li>
<li class="tab has-icon"><span>Meble 48h</span></li>
</ul>
Link to example website: https://dobrzekupuj.pl/
Set a width or max-width to every li
For example
.nav > li {
width: 70px;
}
or
.nav > li {
max-width: 70px;
}
For mobile only put it on a media query
#media (max-width: 480px) {
.nav > li {
width: 70px;
}
}
the table-layout set to fixed seems the best option to wrap all elements at once into 2 lines :
ul {
display: table;
table-layout: fixed;
margin: auto;
border-spacing: 1vw 0;
}
li {
display: table-cell;
}
/* makup/see me */
li {border:1px solid;}
ul {
border-spacing: 1vw 0;
}
* {margin:0;
padding:0;
box-sizing:border-box;
}
<ul class="nav nav-line-bottom nav-normal nav-size-normal nav-center">
<li class="tab active has-icon"><span>Meble fryzjerskie</span></li>
<li class="tab has-icon"><span>Fotele fryzjerskie</span></li>
<li class="tab has-icon"><span>Myjnie fryzjerskie</span></li>
<li class="tab has-icon"><span>Konsolety fryzjerskie</span></li>
<li class="tab has-icon"><span>Pomocniki fryzjerskie</span></li>
<li class="tab has-icon"><span>Meble 48h</span></li>
</ul>
to keep it always shrink to minimun, again the table-layout (not set to fixed here ) seems to be the best option :
ul {
display: table;
width:0;/* will shrink/expand to fit content anyway */
margin: auto;
border-spacing: 1vw 0;
}
li {
display: table-cell;
}
/* makup/see me */
li {border:1px solid;}
ul {
border-spacing: 1vw 0;
}
* {margin:0;
padding:0;
box-sizing:border-box;
}
<ul class="nav nav-line-bottom nav-normal nav-size-normal nav-center">
<li class="tab active has-icon"><span>Meble fryzjerskie</span></li>
<li class="tab has-icon"><span>Fotele fryzjerskie</span></li>
<li class="tab has-icon"><span>Myjnie fryzjerskie</span></li>
<li class="tab has-icon"><span>Konsolety fryzjerskie</span></li>
<li class="tab has-icon"><span>Pomocniki fryzjerskie</span></li>
<li class="tab has-icon"><span>Meble 48h</span></li>
</ul>
Run both snippets in full page to see different behavior.
Note also, that some padding on your original code could also work to set your wrapping point earlier
from your update on codepen, the table-layout can be used only on li too.
.nav>li {
display: inline-table;
}
#media (max-width: 480px) {
.nav>li {
width: 0;
border: solid;
}
}
/* very simplified css*/
<ul class="nav nav-line-bottom nav-normal nav-size-normal nav-center">
<li class="tab active has-icon"><span>Meble fryzjerskie</span></li>
<li class="tab has-icon"><span>Fotele fryzjerskie</span></li>
<li class="tab has-icon"><span>Myjnie fryzjerskie</span></li>
<li class="tab has-icon"><span>Konsolety fryzjerskie</span></li>
<li class="tab has-icon"><span>Pomocniki fryzjerskie</span></li>
<li class="tab has-icon"><span>Meble 48h</span></li>
</ul>
I would insert a <br> tag with a class attached that showed / hid the <br> depending on screen size.
Example:
HTML:
<p>FirstName<br class="line-break">LastName</p>
CSS:
/* Default for mobiles */
.line-break {
display: block;
}
/* For tablets/desktops */
#media only screen and (min-width: 600px) {
.line-break {
display: none;
}
}

Adaptative width with flexbox and flex-grow

I'm trying to set up a menu bar with the
following template
I'm trying this with FlexBox but I can't figure out what's wrong. Here's the HTML :
<nav>
<ul>
<li id="navleft">
<img src="images/logo.png" alt="logo wikihow">
</li>
<li class="navothers">
<img src="images/contribuye.png" alt="contribuye">
<p>CONTRIBUYE</p>
</li>
<li class="navothers">
<img src="images/explora.png" alt="explora">
<p>EXPLORA</p>
</li>
<li class="navothers">
<img src="images/entrar.png" alt="entrar">
<p>ENTRAR</p>
</li>
<li class="navothers"><img src="images/mensajes.png" alt="mensajes">
<p>MENSAJES</p>
</li>
</ul>
</nav>
And I apply the following styles in CSS :
nav {
padding: 0 30% 0 30%;
}
nav ul {
display:flex;
justify-content:center;
align-items:center;
background-color: #93B874;
}
#navleft{
flex-grow:32;
flex-shrink:1;
}
#navleft img{
width: 144px;
vertical-align:center
}
.navothers{
flex-grow:1;
flex-shrink:4;
}
I get the following result
My problem is that all the elements in the right part (with the "navothers" class) dont have the same width ! They just adapt depending on the size of the text they have.
I may have mixed a lot of things, what have I done wrong ?
Your flex-grow value for #navleft is too big, and your container is too small. Your items can't grow they don't have enough room. Try this :
CSS :
nav {
padding: 0 10% 0 10%; // imho it's a strange way to center your nav. Reduced to show you that you're lacking room.
}
nav ul {
display: flex;
justify-content: center;
align-items: center;
background-color: #93B874;
}
#navleft {
flex: 2; // You may tune this one but keep room for your other items !
}
#navleft img {
width: 144px;
vertical-align: center
}
.navothers {
flex: 1;
border: solid 1px #000;
}
HTML :
<nav>
<ul>
<li id="navleft">
<img src="images/logo.png" alt="logo wikihow">
</li>
<li class="navothers">
<img src="images/contribuye.png" alt="contribuye">
<p>CONTRIBUYE</p>
</li>
<li class="navothers">
<img src="images/explora.png" alt="explora">
<p>EXPLORA</p>
</li>
<li class="navothers">
<img src="images/entrar.png" alt="entrar">
<p>ENTRAR</p>
</li>
<li class="navothers">
<img src="images/mensajes.png" alt="mensajes">
<p>MENSAJES</p>
</li>
</ul>
</nav>
https://jsfiddle.net/me7t2hv3/

changing the width of collapsing navbar

I've search and searched but not of the answers are having the desired outcome for some reason.
At the moment my navbar is collapsing at 768px, however I want it to collapse at 1200px instead, I've changed the #media in the CSS files accordingly to reflect this however it just doesn't seem to be taking any effect, what on earth am I doing wrong?
I've tried following the instructions like explained here: Change bootstrap navbar collapse breakpoint without using LESS
but still nothing.
My site is http://www.yourtechgeek.co.uk/
Hope someone can help as I'm really scratching my head now.
TIA
Looking at your site, it is defined for 768 pixels. Change into the following in file bootstrap.min.css or your own css file.
#media (min-width: 1200px)
.container {
width: 750px;
}
to change the navbar break point , for example for the mobile hamburger to appear at 1200px , see this example snippet below
or see fiddle > fiddle
#media (max-width: 1200px) {
.navbar-header {
float: none;
}
.navbar-left,.navbar-right {
float: none !important;
}
.navbar-toggle {
display: block;
}
.navbar-collapse {
border-top: 1px solid transparent;
box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
}
.navbar-fixed-top {
top: 0;
border-width: 0 0 1px;
}
.navbar-collapse.collapse {
display: none!important;
}
.navbar-nav {
float: none!important;
margin-top: 7.5px;
}
.navbar-nav>li {
float: none;
}
.navbar-nav>li>a {
padding-top: 10px;
padding-bottom: 10px;
}
.collapse.in{
display:block !important;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="navbar navbar-default">
<div class="navbar-header">
<a class="navbar-brand" href="#">Bootstrap 3</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="dropdown active">
Getting started <b class="caret"></b>
<ul class="dropdown-menu">
<li>Download Bootstrap</li>
<li class="divider"></li>
<li class="dropdown-header">Examples</li>
<li>Basic template</li>
<li>Starter template</li>
<li>Grids</li>
<li>Jumbotron</li>
<li>Navbar</li>
<li>Sign-in page</li>
<li>Sticky footer</li>
<li>Offcanvas</li>
<li>Carousel</li>
<li>Theme</li>
<li class="divider"></li>
<li class="dropdown-header">Compatibility</li>
<li>Migrating from 2.x to 3.0</li>
<li>Browser support</li>
<li>Third party support</li>
</ul>
</li>
<li>CSS</li>
<li>Components</li>
<li>JavaScript</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="active">Customize</li>
</ul>
</div>
</div>
<div class="jumbotron">
<h1>Twitter Bootstrap 3.0</h1>
<p class="lead">Starter template with CSS and JS included.</p>
<p><a class="btn btn-lg btn-primary" href="#fork">Fork this fiddle</a></p>
</div>
</div>

CSS for email client inbox

I am creating an email client, I want the inbox to resemble that of Mac Mail
I am pulling the emails themselves from a database using ajax (outputting to XML) and then looping through the entries and pulling the relevant elements.
What I have never been confident with is the css. I want to create the elements using <ul> and <li>. My understanding is that I will need to nest these. For example:
<ul>
<li>
<ul>
<li class="from">Mike # Hotmail</li>
<li class="subject">Hello</li>
<li class="date">13/01/2013</li>
<li class="preview">Lorem Ipsum....</li>
</ul>
</li>
<li>
<ul>
<li class="from">Jame # Gmail</li>
<li class="subject">Out Of Office</li>
<li class="date">12/01/2013</li>
<li class="preview">Lorem Ipsum....</li>
</ul>
</li>
.from {
}
.subject {
}
.date {
}
.preview {
}
What I don't know is whether I need to reference the <ul> and <li> items within the CSS, does that make a difference? Also, what are the things that I need to create this look?
PLEASE DO NOT ANSWER THIS. I THINK I HAVE WORKED IT OUT. WHEN I AM HAPPY WITH THE OUTCOME I WILL POST HERE FOR OTHERS TO WORK FROM IN THE FUTURE...
Ok, I give up, this is what I have so far:
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
.inboxPanel {
width: 420px;
}
ul.inbox {
width: 100%;
list-style-type: none;
}
ul.message {
list-style-type: none;
display: block;
}
.from {
width: 50%;
border: 1px solid #ccc;
font-weight: 700;
float: left;
display: inline-block;
}
.subject {
border: 1px solid #ccc;
}
.date {
width: 50%;
border: 1px solid #ccc;
float: right;
display: inline-block;
}
.preview {
border: 1px solid #ccc;
}
</style>
<title></title>
</head>
<body>
<div class="inboxPanel">
<ul class="inbox">
<li>
<ul class="message">
<li class="from">Mike # Hotmail</li>
<li class="subject">Hello</li>
<li class="date">13/01/2013</li>
<li class="preview">Lorem Ipsum....</li>
</ul>
</li>
<li>
<ul class="message">
<li class="from">Jame # Gmail</li>
<li class="subject">Out Of Office</li>
<li class="date">12/01/2013</li>
<li class="preview">Lorem Ipsum....</li>
</ul>
</li>
<li>
<ul class="message">
<li class="from">Mike # Hotmail</li>
<li class="subject">Hello</li>
<li class="date">13/01/2013</li>
<li class="preview">Lorem Ipsum....</li>
</ul>
</li>
<li>
<ul class="message">
<li class="from">Jame # Gmail</li>
<li class="subject">Out Of Office</li>
<li class="date">12/01/2013</li>
<li class="preview">Lorem Ipsum....</li>
</ul>
</li>
</ul>
</div>
</body>
</html>
Ok, first of all
<ul>
<li class="from">Mike # Hotmail</li>
<li class="subject">Hello</li>
<li class="date">13/01/2013</li>
<li class="preview">Lorem Ipsum....</li>
</ul>
makes no sense semantically. From, subject, date and preview are not a list. Your email messages ARE a list, but the email components are not.
What you should do is something like this:
<ul>
<li>
<span class="from"></span>
<span class="date"></span>
<p class="subject></p>
<p class="preview"></p>
</li>
<ul>
CSS:
li { overflow: hidden; }
li span.from { float: left; font-weight: bold; }
li span.date { float: right; }
li p.subject { clear: both; font-weight: bold; }
li p.preview { color: #ccc; }
This is just rough styling to make the layout look the way you want. You'll have to tweak it for proper padding, colors, etc.