Image Height is distorted - css

I'm creating a resume website. I'm adding content to the Job.js component, and I'm encountering an issue with logo. The height seems to expand when the desc exceeds the height of the component. If the desc is short, I do not have this issue. I'm also not having this problem when flex-direction is column.
I tried adjusting padding-bottom of .job-container img, but while the image returned to normal, there was unwanted padding at the bottom.
Relevant Code
Job.js
import React from 'react';
import '../css/Job.css';
function Job(props) {
console.log(props.name);
const jobList = props.job.map(j =>
<div className='job-container'>
<img src={j.logo} alt={j.alt} />
<div className='description'>
<div>
<a href={j.link} rel='noopener noreferrer' target='_blank'>
{j.companyName}
</a>
</div>
<div>{j.title}</div>
<div>{j.duration}</div>
<div>{j.location}</div>
<div>{j.desc.map(paragraph => <p>{paragraph}</p>)}</div>
</div>
</div>
)
return (
<div>{jobList}</div>
);
}
export default Job;
Job.css
:root {
--image-spacing: 30px;
}
.job-container {
border: 2px solid red;
padding: 0px 5%;
display: flex;
flex-direction: row;
}
.job-container img {
border: 2px solid red;
border-radius: 3px;
display: block;
height: auto;
width: 35%;
}
.job-container .description {
line-height: 1.45;
padding-left: var(--image-spacing); /* Change this. */
}
.job-container a {
color: black;
text-decoration: none;
}
/* Responsive Mode */
#media only screen and (max-width: 768px) {
.job-container {
/* Line up description and image. */
flex-direction: column;
}
.job-container img {
border-radius: 3px;
margin: auto;
width: 75%;
}
.job-container .description {
padding-left: 0px;
padding-top: var(--image-spacing);
}
}
.content {
display: block;
}

I solved this problem by adding align-self: start; to .job-container img.

Related

Move on click - html, css only - media queries

I have a link on my menu items and id's on h2 of the text that belong to it. All I want to do is easy - when I click on certain item in the menu I want it to move down to the text that belongs to it. Easy.
I have it like side menu on the left and next to it is the text. When the resolution is under 479px the "side menu" is at the top and the text is under it. And what I want it to do is only when it is under this resolution - to jump down to the text (h2). When is it side by side it is fine and there is no need to do that of course. So my question is.. is it posiible to do so somehow only by using html and css? To make it work ("jump") only when it is under 479px? Media queries somehow?
Thanks you
<section id="budova">
<div class="materials">
<div class="container">
<h1>BUDOVA (izolace)</h1>
<div class="materials-container">
<div class="kategorie">
<h2 data-kategorie="#silsonic" class="active">Silsonic</h2>
<h2 data-kategorie="#mappysil400">Mappysil CR 400</h2>
<h2 data-kategorie="#mappysil404">Mappysil CR 404</h2>
<h2 data-kategorie="#polistik">Polistik / M under special HQ</h2>
<h2 data-kategorie="#pavisol">Pavisol</h2>
<h2 data-kategorie="#mappysilent">Mappysilent</h2>
<h2 data-kategorie="#fonosilent">Fonosilent</h2>
<h2 data-kategorie="#bugnato">Mappysil CR Bugnato</h2>
<h2 data-kategorie="#mappysil-re">Mappysil CR RE</h2>
<h2 data-kategorie="#mappypren">Mappypren AU</h2>
<h2 data-kategorie="#stopfire">Stopfire Bugnato</h2>
</div>
<div class="produkty" id="produkty">
<div id="silsonic" class="active">
<h3>Silsonic</h3>
<img src="./img/materials/budova/silsonic.jpg" alt="Silsonic">
<p>Cena od 150 kč vč. DPH</p>
<p>v 40/š 600/d 1200 mm ( ostatní rozměry v sekci ceník )</p>
<p>SILSONIC je termoizolační a akusticky absorpční materiál vyrobený z tepelně zpracovaných, recyklovaných polyesterových vláken. Panely SILSONIC se používají k tepelné a zvukové izolaci všech druhů zdiva, sádrokartonových konstrukcí, stropů a pro podstřešní izolace.</p>
</div>
.
.
.
more text
CSS
.materials-container {
display: grid;
grid-template-columns: 1fr 3fr;
margin: 3rem 0;
}
.materials h1 {
text-align: center;
padding: 6rem 0 1.5rem;
font-family: "Montserrat", sans-serif;
font-weight: 300;
letter-spacing: 1px;
border-bottom: 1px solid;
width: 90%;
margin: auto;
}
.kategorie {
background-color: #c4c4c4;
text-align: center;
padding: 1rem 0;
border-radius: 10px;
margin-bottom: 8rem;
}
.produkty {
display: flex;
justify-content: center;
/* align-items: center; */
margin-left: 10rem;
}
.produkty div {
display: none;
}
.produkty div.active {
display: initial;
}
.produkty h4 {
text-transform: uppercase;
margin-top: 3rem;
}
.produkty p:first-of-type,
.produkty p:nth-of-type(2) {
font-weight: 600;
}
.produkty img {
max-width: 300px;
}
.materials {
padding-bottom: 40px;
}
.materials p {
line-height: 24px;
}
.materials h1 {
margin-bottom: 5rem;
}
.materials h2 {
width: 70%;
cursor: pointer;
font-size: 1.2rem;
font-weight: 300;
padding: 0.8rem 0;
border-bottom: 1px solid transparent;
margin: 0 auto;
transition: all 0.3s;
}
.materials h2:hover {
border-bottom: 1px solid #fff;
color: #fff;
}
#media (max-width: 479px) {
.main-text p {
line-height: 2rem;
}
.main-text h1 {
padding: 4rem 0 0.5rem;
}
.photos img {
width: 60%;
margin: auto;
}
.photos {
height: 160px;
}
.nav-menu .logo {
width: 53%;
height: 52px;
}
.materials-container {
display: block;
}
.materials h2 {
font-size: 1.2rem;
}
.kategorie {
margin-bottom: 5rem;
}
#fonosilent {
width: 100%;
}
}
make an extra "link" in the html
on small screens one will be hidden (the one without jump-to-link) while the other one (with anchor-tag and jump-to) will be shown.
...
<div class="kategorie">
<h2 data-kategorie="#silsonic" class="active">Silsonic</h2>
<h2 data-kategorie="#silconic" class="active big-screen">Silsonic</h2>
...
media-queries in css:
#media (max-width: 479px) {
.big-screen {
display: none;
}
.small-screen {
display: grid/flex/whatever;
}
}
#media (min-width: 480px) {
.big-screen {
display: grid/flex/whatever;
}
.small-screen {
display: none;
}
}

How can I keep all my navbar icons in one row when viewing from a mobile device in React?

I am making a pretty simple bottomnav for a project I am working on, and I am having difficulty with the view in mobile mode. From standard desktop, I have a pretty simple, bottomnav with 4 icons, however when I inspect the page in mobile view, it only shows you either the first, or the first and 2nd icon. all of my styling for this component is:
/* Place the navbar at the bottom of the page, and make it stick */
.navbar {
background-color: rgb(75, 90, 72);
overflow: hidden;
position: absolute;
bottom: 0;
min-width:800px;
height:64px;
/* width: 100%; */
}
.navCont {
text-align: center;
position: fixed;
bottom: 0;
width: 100%;
}
.navButton {
margin-left:10vh;
margin-right:10vh;
min-width:10px;
}
.navButtonLeft {
margin-left:10vh;
margin-right:10vh;
min-width:10px;
}
/* Style the links inside the navigation bar */
.navbar a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
/* Change the color of links on hover */
.navbar a:hover {
background-color: #ddd;
color: black;
}
/* Add a color to the active/current link */
.navbar a.active {
background-color: #4CAF50;
color: white;
}
img {
width:32px;
height: auto;
float:left;
margin-bottom: 20px;
}
#media screen and (max-width: 100px) {
.navbar {
display: inline-block;
height:64px;
}
.navCont {
display: flex;
align-content: space-between;
}
.navButton,
.navButtonLeft {
padding: none;
display: inline-block;
}
img {
display: inline-block;
}
}
Any advice or tips would be greatly appreciated!
edit: Here is the component i am working with.
import React from "react";
import home from "./home.png"
import post from "./post.png"
import profile from "./profile.png"
import search from "./search.png"
import "./Footer.css";
class Footer extends React.Component {
render() {
return (
<div class="navCont">
<div class="navbar">
<img src={home} alt="home icon"/>
<img src={profile} alt="home icon"/>
<img src={post} style={{width:"44px", height: "auto"}} alt="home icon"/>
<img src={search} style={{width:"44px", height: "auto"}} alt="home icon"/>
</div>
</div>
);
}
}
export default Footer;
I've revamped your css to use flexbox for laying out the icons in a row; got rid of all the floats and some other rules that seemed unnecessary. I'm not sure this does exactly what you're trying to do (since I don't know exactly what you're trying to do) but I think this is at least a better starting point.
.navCont {
position: fixed;
left: 0;
right: 0;
bottom: 0;
width: 100%;
background-color: rgb(75, 90, 72);
}
.navbar {
height: 64px;
display: flex;
justify-content: center;
}
/* Style the links inside the navigation bar */
.navbar > * {
flex: 0 0 auto;
padding: 14px 16px;
}
/* Change the color of links on hover */
.navbar a:hover {
background-color: #ddd;
color: black;
}
img {
width: 32px;
max-width: 100%;
height: auto;
}
<div class="navCont">
<div class="navbar">
<a href="/" class="navButton">
<img src="https://via.placeholder.com/64x64.png/fff/000/?text=A" />
</a>
<a href="Profile" class="navButton">
<img src="https://via.placeholder.com/64x64.png/fff/000?text=B" />
</a>
<a href="Post" class="navButton">
<img src="https://via.placeholder.com/64x64.png/fff/000?text=C" />
</a>
<a href="Search" class="navButton">
<img src="https://via.placeholder.com/64x64.png/fff/000?text=D" />
</a>
</div>
</div>

CSS Grid - Why is my text being cut off when I resize to smaller screens?

Like the title says, it is only the text at the far right off the screen that is cut off, when I inspect and view smaller device sizes.
Here is my HTML:
* {
margin: 0;
}
body {
overflow-x: hidden;
}
.wrapper1 {
display: grid;
grid-template-columns: 6fr 3fr;
border: 2px solid #6cccb0;
overflow: hidden;
height: 30px;
background-color: #6cccb0;
width: 1700px;
}
<div class="wrapper1">
<div>
<p class="item1">SHIPPED for free | GUARANTEED TO LAST</p>
</div>
<div>
<p class="item2">LOG IN | REGISTER | CUSTOMER SERVICE | 1-800-692-8259 </p>
</div>
</div>
Thanks
Why not remove the hard-set width and the overflow: hidden properties? These are causing your content to be both offscreen and also cut.
* {
margin: 0;
}
.wrapper1 {
display: grid;
grid-template-columns: 2fr 1fr;
align-items: center;
border: 2px solid #6cccb0;
background-color: #6cccb0;
}
<div class="wrapper1">
<div>
<p class="item1">SHIPPED for free | GUARANTEED TO LAST</p>
</div>
<div>
<p class="item2">LOG IN | REGISTER | CUSTOMER SERVICE | 1-800-692-8259 </p>
</div>
</div>
You could use
width: 100%;
instead of
width: 1700px;
So your item2 text will not disappear.
Edit 1:
In case you want to keep your text in one line, I suggest using #media queries to change your font-size. so your css must be something like this.
* {
margin: 0;
}
.wrapper1 {
display: grid;
grid-template-columns: 2fr 2fr;
border: 2px solid #6cccb0;
height: 30px;
background-color: #6cccb0;
font-size: 1em;
color: orange;
}
#media only screen and (max-width: 440px) {
.wrapper1 {
font-size: 0.4em;
color: yellow;
}
}
#media only screen and (min-width: 440px) {
.wrapper1 {
font-size: 0.5em;
color: aqua;
}
}
#media only screen and (min-width: 560px) {
.wrapper1 {
font-size: 0.6em;
color: green;
}
}
#media only screen and (min-width: 728px) {
.wrapper1 {
font-size: 0.8em;
color: blue;
}
}
#media only screen and (min-width: 1024px) {
.wrapper1 {
font-size: 1em;
color: red;
}
}
I put color rules to help you understand what's happening. You can delete them. I hope it would help you.

css text in border and border under text

Hi there I am new to css and to stackoverflow and need some help. I am trying to create something like this with css:
image
But I really don't get these results, can someone help me? thanks
I created a snippet which looks like the image you were trying to re-create. Hope it helps.
Useful links -
::after / ::before, flexbox
.hr-sect {
display: flex;
flex-basis: 100%;
align-items: center;
margin: 8px 0px;
}
.hr-sect::before,
.hr-sect::after {
content: "";
flex-grow: 1;
height: 2px;
font-size: 0px;
line-height: 0px;
margin: 0px 20px;
}
.hr-sect,
span {
color: blue;
}
.hr-sect::before,
.hr-sect::after {
background-color: blue;
}
hr {
border: 1px solid blue;
}
.title {
text-align: center;
}
.big {
font-size: 25px;
}
<div class="title">
<div class="hr-sect"><span>HOW TO GET</span></div>
<span class="big">GALAXY SKIN FORTNITE</span>
<hr>
</div>

Border Radius only for the first and last child

Here is my problem:
I need rounded border only for first and last element? How can I accomplish that?
This is my css:
.root {
display: flex;
width: 100%;
height: 56px;
align-items: center;
border-radius: var(--radius-medium)px;
border: 1px solid var(--color-gray2);
}
.icon {
display: flex;
align-items: center;
padding: 0 15px;
}
.text {
color: #000;
font-size: calc(var(--font-size-body) / 10)rem;
}
This is from React:
//<ListElementRoot> === .root
//<ListElementIcon> === .icon
//<ListElementText> === .text
return (
<ListElementRoot>
<ListElementIcon>
<Icon name={icon} color={color} />
</ListElementIcon>
<ListElementText>
{children}
</ListElementText>
</ListElementRoot>
)
}
That is all, I know I should do something with first and last element, but how to do it in my case? Any ideas?
Borders are generated by root...
I suppose you mean that the first and last one should still have non-rounded edges at the inner sides:
.root {
width: 200px;
height: 80px;
border: 1px solid black;
}
.root:first-of-type {
border-top-left-radius: 10px;
border-top-right-radius: 10px;
}
.root:last-of-type {
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
}
<div>
<div class="root">1
</div>
<div class="root">2
</div>
<div class="root">3
</div>
<div class="root">4
</div>
</div>
You can use :first-child and :last-child for this:
.root { /* all .root */
display: flex;
width: 100%;
height: 56px;
align-items: center;
border: 1px solid var(--color-gray2);
}
.root:first-child, .root:last-child { /* first or last .root only */
border-radius: var(--radius-medium)px;
}

Resources