Padding-bottom does not apply for divs - css

I'd like to move up the stack list a little but it moves only when I apply padding-bottom to the main-container class, which moves the image as well. I want to fix the location of the image and move only the stack list. I'm calling a ProjectBox component from ProjectMain. How should I do that?
ProjectMain.js
import React, { Component } from "react";
import ProjectBox from "./ProjectBox";
export class ProjectMain extends Component {
render() {
return (
<div className="project-main-box">
<div className="project-header">
<div className="header-wrapper">
<div className="project-bullet"></div>
<div className="project-name">Projects</div>
<h4>You can see the websites if you click them</h4>
</div>
</div>
<ProjectBox />
</div>
);
}
}
export default ProjectMain;
ProjectBox.js
import React, { Component } from "react";
import TestImg from "../../test.jpg";
export class ProjectBox extends Component {
render() {
return (
<div className="main-container">
<div className="proj-description">
<div className="description-header">
<h4>CoronaTrace</h4>
</div>
<p>
A website that shows current covid19 cases over the states in the US
with graphs and a table.
</p>
<div className="stacks">
<h6>Stacks Used: </h6>
<ul>
<li>ReactJS</li>
<li>Bootstrap</li>
<li>Express</li>
<li>MongoDB Atlas</li>
<li>Recharts</li>
<li>Heroku</li>
</ul>
</div>
</div>
<div className="img-container">
<a
href="https://www.google.com"
target="_blank"
rel="noopener noreferrer"
>
<img
src={TestImg}
height="100%"
width="100%"
alt="Img Not Found"
></img>
</a>
</div>
</div>
);
}
}
export default ProjectBox;
App.scss
#mixin project-box {
background-color: white;
height: 400px;
width: 700px;
margin: auto;
overflow: hidden;
-webkit-box-shadow: 0 0 15px 3px #b0abaa;
-moz-box-shadow: 0 0 15px 3px #b0abaa;
box-shadow: 0 0 15px 3px #b0abaa;
}
/* Projects Style */
.project-main-box {
background-color: #ede7dd;
height: 100%;
// project header style
.project-header {
position: relative;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
.header-wrapper {
padding: 0;
margin: 70px 0 50px 0;
.project-bullet {
#include bullet;
margin-bottom: 4px;
height: 20px;
width: 20px;
}
.project-name {
display: inline-block;
margin-bottom: 40px;
margin-left: 5px;
font-size: 50px;
font-weight: bold;
}
}
}
// ProjectBox Component Style
.main-container {
#include project-box;
margin-bottom: 80px;
.proj-description {
display: inline-block;
width: 55%;
.description-header {
background: blue;
width: 10px;
height: 50px;
h4 {
margin-left: 35px;
font-weight: bold;
color: blue;
}
}
p {
margin: 40px 30px;
}
.stacks {
margin: 0 30px;
}
}
.img-container {
width: 45%;
height: 100%;
display: inline-block;
padding: 0;
overflow: hidden;
}
}
}
It's what it looks like now.

Related

react.js text div wont scale with my page but the image div will

I am doing this website for my full stack web development course but I am having a bit of trouble with my css. I am wondering how I can get the text Div to scale with the page.
the div looks like this zoomed in,
and it looks like this zoomed out,
the text div always wants to stay the same size.
the css is
.waitingMainDiv {
width: 70%;
display: flex;
justify-content: center;
align-items: center;
margin: auto;
padding-top: 80px;
padding-bottom: 80px;
}
.waitingLeftDiv {
width: 100%;
height: auto;
}
.waitingLeftDivImage {
width: 100%;
height: auto;
}
.waitingRightDiv {
width: 100%;
height: auto;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.waitingTextDiv {
width: 85%;
color: grey;
}
.waitingTextDiv h2 {
font-family: nunito;
font-weight: 700;
font-size: 2.3em;
margin: 4%;
}
.waitingTextDiv h3 {
font-family: nunito;
margin: 30px;
}
.waitingTextDiv p {
font-family: nunito;
margin: 30px;
font-size: 1.2em;
}
.waitingButtonDiv {
display: flex;
justify-content: flex-start;
width: 85%;
margin-left: 50px;
}
.waitingButtonDiv button {
width: 180px;
border-radius: 8px;
box-shadow: 0px 2px 5px rgb(0, 0, 0, 0.4);
font-family: nunito;
font-weight: 800;
}
.waitingEnquireButton {
border: 2px solid #43c0f6;
background-color: white;
color: #707070;
margin-right: 100px;
}
.waitingSignUpButton {
border: 2px solid #f91c85;
background-color: #f91c85;
color: white;
}
and the react.js is
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js">
import teacherPicture from "../../../../img/teacherPicture.png";
import React, { useState } from "react";
import "./Waiting.css";
import NavModal from "../../../Nav/NavModal";
export default function Waiting() {
const [open, setOpen] = useState(false);
const handleOpen = () => {
setOpen(true);
};
const handleClose = () => {
setOpen(false);
};
return (
<div className="waitingMainContainer">
<div className="waitingMainDiv">
<div className="waitingLeftDiv">
<img className="waitingLeftDivImage" src={teacherPicture} alt="" />
</div>
<div className="waitingRightDiv">
<div className="waitingTextDiv">
<h2>What are you waiting for?</h2>
<h3>Start teaching Digital Technologies today.</h3>
<p>
If you need more information, we are happy to answer any questions
you may have.
</p>
</div>
<div className="waitingButtonDiv">
<button className="waitingEnquireButton">ENQUIRE NOW</button>
<button
onClick={() => handleOpen()}
className="waitingSignUpButton"
>
SIGN UP
</button>
<NavModal open={open} handleClose={handleClose} />
</div>
</div>
</div>
</div>
);
}
</script>
Thankyou to those who review my code, its definitely a simple fix but im driving myself crazy over it.
Give your main div a width, not %;
.waitingMainDiv {
width: 70vw; //changed
display: flex;
justify-content: center;
align-items: center;
margin: auto;
padding-top: 80px;
padding-bottom: 80px;
}

Css / Styled Cutting a div as a ballon question

Hello i'm trying to do like an arrow from a question balloon:
code:
<Styled.MessageWrapper user={message.user}>
<Styled.BotImg src={BotLogo} user={message.user} />
<Styled.ChatMessage user={message.user}>
{message.text}
</Styled.ChatMessage>
</Styled.MessageWrapper>
css:
const MessageWrapper = styled.div`
display: flex;
align-items: center;
justify-content: ${props => (props.user ? 'flex-end' : 'flex-start')};
`;
const BotImg = styled.img`
display: ${props => (props.user ? 'none' : 'block')};
padding-left: 10px;
width: 40px;
`;
const ChatMessage = styled.div`
margin: 1ex;
padding: 1ex;
border-radius: 2px;
${props => (props.user ? messageClient : messageBot)}
`;
now i have this:
i trying make this but not sucess:
Unfortunately, I don't know anything about styled components. However, this solution with just HTML and CSS might help demonstrate how to leverage the technique already recommended by #BugsArePeopleToo.
.messages {
max-width: 400px;
margin: 0 auto;
}
.message {
margin: 0.5em;
}
.message.tx {
text-align: right;
}
.message .bubble {
position: relative;
display: inline-block;
vertical-align: top;
background: #0D47A1;
color: #fff;
padding: 0.5em 1em;
border-radius: 0.5em;
}
.message.rx .bubble {
background: #CFD8DC;
color: #212121;
}
.message .icon {
display: inline-block;
width: 2em;
height: 2em;
margin-right: 0.5em;
border-radius: 1em;
background: #CFD8DC;
}
.bubble.l-caret::before,
.bubble.r-caret::before {
position: absolute;
display: block;
content: '';
top: 0;
width: 0;
height: 0;
border-left: 0.5em solid transparent;
border-right: 0.5em solid transparent;
border-top: 0.5em solid #0D47A1;
}
.message.rx .bubble.l-caret::before,
.message.rx .bubble.r-caret::before {
border-top: 0.5em solid #CFD8DC;
}
.bubble.l-caret::before {
left: -0.5em;
}
.bubble.r-caret::before {
right: -0.5em;
}
<div class="messages">
<div class="message rx">
<span class="icon"> </span>
<span class="bubble l-caret">
test 123 hello world <br>
multiline
</span>
</div>
<div class="message tx">
<span class="bubble r-caret">
ohai
</span>
</div>
</div>
You need a pseudo element on your ChatMessage component.
The syntax for styled components is:
const ChatMessage = styled.div`
position: relative;
&:before {
position: absolute;
/* additional pseudo element styles here */
}
`;
As for the styles of the arrow, you need relative/absolute positioning, and use the transparent border trick to get a triangle. Here is anther question on SO that explains this technique very well, just adjust the positioning, dimensions, color, border, etc to your liking: Speech bubble with arrow

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>

Certain letters overflowing their container - can anything be done?

I have noticed the problem of certain letters overflowing their container on the left side, but I haven't seen anyone actually bringing up the problem.
I've tried between a few different font-families, but they all seem to have the same problem.
JSFIDDLE: https://jsfiddle.net/3h5poynt/
HTML (angular)
<div class="personal-profile container-column">
<mat-card class="header">
<section class="cover-section"></section>
<section class="intro-section">
<div class="intro-header">
<div class="profile-photo-wrapper">
<img src="/assets/img/profile-picture-placeholder.png" alt="" class="profile-photo" />
</div>
<div class="badges-container">
<ul class="badges-list">
<li>
<img
src="/assets/badges/business-plans-180x180.png"
alt="Business plan"
matTooltip="Something"
matTooltipClass="badge-tooltip"
matTooltipPosition="above"
/>
</li>
<li><img src="/assets/badges/calling-customers-180x180.png" alt="Calling customers" /></li>
<li><img src="/assets/badges/finance-180x180.png" alt="Finance" /></li>
<li>
<img src="/assets/badges/selling-to-customers-180x180.png" alt="Selling to customers" />
</li>
<li><img src="/assets/badges/social-media-180x180.png" alt="Social media" /></li>
</ul>
</div>
</div>
<div class="info-container">
<div class="personal-info">
<div class="name-text">{{ profile ? profile.name : '' }}</div>
<div class="description">{{ profile ? profile.personal_description : '' }}</div>
</div>
<div class="additional-info"></div>
</div>
</section>
</mat-card>
SCSS
#import '../../../variables';
.mat-card {
padding: 0;
overflow: hidden;
section {
padding: 20px;
}
}
.badge-tooltip {
background: #3f51b5;
color: white;
font-family: $font-open-sans;
}
.personal-profile {
margin-top: 50px;
.header {
min-height: 500px;
width: 100%;
.cover-section {
background: url('/assets/img/coverpicture.png') center/cover;
height: 225px;
}
.intro-section {
.intro-header {
size: auto;
.profile-photo-wrapper {
position: relative;
margin-top: -87px;
display: inline-block;
.profile-photo {
width: 150px;
height: 150px;
border: 4px solid white;
border-radius: 10px;
box-shadow: inset 0 1.5px 3px 0 rgba(0, 0, 0, 0.15), 0 1.5px 3px 0 rgba(0, 0, 0, 0.15);
background-color: #fff;
}
}
.badges-container {
vertical-align: middle;
display: inline-block;
margin-top: -87px;
.badges-list {
list-style: none;
li {
float: left;
padding: 0 10px 0 10px;
img {
width: 40px;
height: 40px;
}
}
}
}
}
.info-container {
padding-top: 15px;
display: grid;
grid-template-columns: 1fr 1fr;
font-family: $font-open-sans;
.personal-info,
.additional-info {
display: flex;
flex-direction: column;
}
.personal-info {
.name-text {
font-size: 1.3em;
}
}
}
}
}
}
Main SCSS
/* You can add global styles to this file, and also import other style files */
#import '~#angular/material/prebuilt-themes/indigo-pink.css';
#import '_variables.scss';
* {
margin: 0;
padding: 0;
font-family: $font-open-sans;
}
html {
font-family: 'Roboto', sans-serif;
}
html,
body {
height: 100%;
width: 100%;
background-color: #e9ebee;
}
.container-column {
display: flex;
flex-direction: column;
width: 80%;
margin: auto;
}
.container-row {
display: flex;
flex-direction: row;
width: 80%;
margin: auto;
}
Is there something very essential that I am missing, or is this something that has to be hacked?
Jonas,
Some fonts are "just like that".
You will find that (especially with some of the more amateurish free fonts available nowadays) that some fonts' descenders, ascenders, ornaments, etc just overlap the borders that we (programmers, readers) expect them to conform to.
If you really want to use a font like this in this specific context, then you have to program around the font's limitations.
In your fiddle, I merely added padding-left to the name-text style:
.name-text{
font-size: 1.3em;
font-family: "Open Sans", sans-serif;
background: red;
padding-left:15px; /* voila! */
}
Give it a try in the fiddle.
If the left bearing is radically different on initial characters across the font, then you maybe able to set up various styles with padding that changes according to the substring value of the first character. Sounds like a bit of a living hell to program that, but if you really want it, there you go.
Or you could just pick a different font.

CSS, express and bootstrap : layout in the page

I would like to have this layout : What I would like
The "Resultat" label should be placed under the image.
Unfortunately, what I get is : What I get
You can see that the "Résultat" label is not well situated.
Here is my CSS :
body {
background-color: #A6A4AA !important;
}
.mainContainer {
background-color: #A6A4AA
}
.label-selected, .label-unselected, .label-result, .result-field, .label-univers, .label-target {
border: solid medium #2C3756;
border-radius: 10px;
background-color: #E6F0BB;
color: #405E01;
font-size: 0.75em;
padding: 5px;
text-align: center;
}
.label-target, .label-result, .result-field {
margin-top: 2px;
font-size: 0.875em;
margin-bottom: 0;
background-color: #2C3756;
text-align: left;
color : #FFFFFF;
border-radius: 8px;
}
.label-target {
border-radius: 8px 8px 0 0;
}
.label-result, .result-field {
margin-bottom: 2px;
}
.result-field {
background-color: #FFFFFF;
color: #2C3756;
border-color: #FFFFFF;
}
.targetImage {
margin: 0;
width: 100%;
height: auto;
border: solid medium #2C3756;
border-radius: 0 0 8px 8px;
background-color: #A6A4AA;
position: relative;
}
#targetCol {
overflow: hidden;
position: absolute;
}
.ajustement {
opacity: 0.5;
}
.label-result, .result-field {
float: none !important;
}
And here is my express code :
<div class="row"> <!-- Row : target -->
<div class= "col-xs-12" id="targetCol">
<img id="target" class="targetImage"></img>
<div id="ajustement" class="ajustement"></div>
<div id="impact" class="impact"></div>
</div>
</div>
<div class="row"> <!-- Row : result -->
<div class= "col-xs-3 short-div">
<p class="label-result">Résultats</p>
</div>
<div class= "col-xs-9 short-div">
<p class="result-field" id="resultField">...</p>
</div>
</div>
Can anyone explain to me what's going on ?
Thank by advance.
I think because you are using position: relative for displaying your image. It sets itself independent from the other div. Try using a div for you image and do not use position instead of that use width:100%;height:xyz px;. Avoid using position set it by giving width or using bootstrap column.

Resources