Footer image not on the same Line with Footer Text - css

I want the image / logo on the footer to be on the same line as the text on the footer, but whatever I do,it goes below the Line and looks like this
My css code is looking like this
.header{
background-color: #007FC0;
width: 100%;
padding: 25px 0;
}
.container{
flex : 1 1 auto;
color:white;
}
.needhelpText{
text-align: right;
font-weight: bold;
color: white;
display: inline-block;
padding: 10px;
float: right;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-size: medium;
}
.copyrightText{
margin: 8px;
color: white;
font-size: 13px;
}
.footerLinks{
color: white;
display: inline-block;
font-size: 13px;
text-decoration: none;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.footerLogo{
float: right;
width : 134px;
height: 40px;
padding: 10px;
align-items: center;
display: inline-block;
}
.footer{
position: fixed;
left: 0;
padding: 10px;
bottom: 0;
width: 100%;
height: 70px;
background-color: #16192C;
}
My React Code looks like this
import React from 'react';
import './app-styles.css';
import Vector from './Vector.png'
import ie_logo from './ie_logo.png';
import {Link} from 'react-router-dom';
function HomePage() {
return (
<div className="App">
<header className="header">
<img src={Vector} style={{margin:7, flexDirection:'column', alignItems: 'center'}} alt="Vector" />
<img src={ie_logo} style={{margin:7, flexDirection: 'row', width:114, height:25}} alt="ie_logo" />
<p className="needhelpText">LOGIN HERE?</p>
</header>
<form>
<label>
Hello React Label
</label>
</form>
<footer className="footer">
Privacy Policy |
Do Not Sell My Personal Information |
Advertising Guidelines |
Site Map
<div className="copyrightText">
© Copyright 2021 | Luther Corp | All Rights Reserved
</div>
<img src={ie_logo} style={{margin:9}} className="footerLogo" alt="ie_logo" />
</footer>
</div>
);
}
export default HomePage;
The Css holding this is the footer Logo which is this one
.footerLogo{
float: right;
width : 134px;
height: 40px;
padding: 10px;
align-items: center;
display: inline-block;
}
Pls what am I missing? Is there something I missed?

Have you tried out giving your footer a 100% width attribute? And if so, please also check the width of the logo. Incase that doesn't work out you can always create a div with 100% width containing only the logo. Than give that dive a text-align:right; attribute.

It's hard to see what's going on without a logo, but I think the footerLogo css height and inline-block are clashing.
If you want to have all the child elements in the same line whilst keeping their height the same (and therefore centered), use a display: flex on the parent without flex wrap. You can then use css margin-left: auto on the logo to make it float to the right and whatever height you want.
PS: align-items property does not work unless the container is display:flex. And it's confusing to add style when there's a class (unless the style is dynamically determined).

Related

Background-color not applying to child elements of a flex navbar

Have a parent Nav with 2 divs inside, Background color of nav does not apply to them
What entire page looks like
What navbar looks like
export default function Header(){
return(
<nav className='nav'>
<img src={react} alt="React"/>
<div className='facts'>ReactFacts</div>
<div className='course'>React Course - Project 1</div>
</nav>
)
}
nav{
background-color: #21222A;
display: flex;
align-items: center;
height: 91px;
padding: 20px 25px;
}
nav > img{
height: 40px;
}
.facts{
margin-left: 12px;
font-size: 22.2535px;
font-weight: 700;
letter-spacing: -0.05em;
color: #61DAFB;
}
nav .course{
margin-left: auto;
color: #DEEBF8;
font-weight: 600;
font-size: 16px;
}
I applied the background color property specifically to both the divs and it worked, but im sure thats just a temporary workaround and would like a more permanent solution
You could remove the display: flex; from the nav element and use a class on the child elements like nav-item and set the background-color on it.
nav-item{
background-color: #21222A;
}

Moving a tag to the top of a todo bar

The spent text with the teal background is meant to be a tag, and I want the tag to appear above the todo bar...kind of like this:
Like a small rectangle on top of a big one. So the tag would be on the top left corner of the todo bar. How would I achieve this? I've tried doing margin to the tag, but that did not work out at all.
CSS for the tag (style.css)
.tag {
color: white;
font-size: 15px;
font-weight: 400;
letter-spacing: 2px;
text-transform: uppercase;
background: #36d1dc;
padding: 3px;
border-radius: 5px;
border-bottom-left-radius: 0px;
border-bottom-right-radius: 0px;
}
React JS code for the tag part (Todo.js)
<li className={`todo-item${todo.completed ? "completed" : ""}`}>
{isSpent && <p className="tag">Spent</p>}
{isReceived && <p className="tag">Received</p>} ${text}
</li>
In case anyone needs the whole of the todo.css file: https://pastecode.io/s/s5XZ9e3DRW
If you need anymore information, or if my question was poorly phrased, please tell me. Any help is very much appreciated. Thank you!
I think if yow will separate the tag and the navbar to two different div tags and put them on main div something like:
<div id="wrapper">
<div id="top-left">top left div</div>
<div id="down">down side div</div>
</div>
and the css will be something like (using grid on the main div):
#wrapper {
display: grid;
}
#top-left {
background: green;
width: 250px;
float:left;
margin-right: 20px;
}
#down {
background: blue;
float:left;
width: 500px;
}
the result is:
I would go with something like this, where input:focus could be a class set on on .container, for example, if the input has any values.
I couldn't understand why you used li and p in your original code, because you need to override so much stuff to make it look nice.
Using "rem" over a fixed pixel value is also preferred if you want to create a responsive site, where you just override the font-size in the body to make everything scale.
.container {
position: relative;
display: flex;
}
body,
input {
padding: 1rem;
}
.container.selected > .todo-item,
input:focus ~ .todo-item {
transform: translateY(-1rem);
}
.todo-item {
position: absolute;
left: 1rem;
transform: translateY(1rem);
transition: transform 400ms;
}
.tag {
color: white;
font-size: 15px;
font-weight: 400;
letter-spacing: 2px;
text-transform: uppercase;
background: #36d1dc;
padding: 3px;
border-radius: 5px;
border-bottom-left-radius: 0px;
border-bottom-right-radius: 0px;
}
<div class="container">
<input type="number">
<div class="todo-item"><span class="tag">Spent</span></div>
<div style="padding-top: 1rem"><-- select this input</div>
</div>
<div class="selected container" style="padding-top: 2rem">
<input type="number">
<div class="todo-item"><span class="tag">Spent</span></div>
</div>
body {
background-color: #48AEE0;
}
.container {
height: 200px;
width: 500px;
display: flex;
flex-direction: column;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.tag {
color: white;
font-size: 15px;
font-weight: 400;
letter-spacing: 2px;
text-transform: uppercase;
background: #36d1dc;
padding: 3px;
width: 80px;
text-align: center;
border-radius: 5px;
border-bottom-left-radius: 0px;
border-bottom-right-radius: 0px;
}
.other {
margin: 0;
display: inline-flex;
flex-direction: column;
}
input {
height: 30px;
width: 200px;
border: white;
margin: 0;
}
<div class="container">
<div class="tag">spent</div>
<div class="others">
<input type="text">
</div>
</div>

Align Horizontal Rule in Css, Not aligning properly

How can I do something like this?
The Orange Line should be on the same Line as the Instruction Text, I have this as my CSS Code
.InstructionText{
margin-bottom: auto;
font-family: Arial, Helvetica, sans-serif;
font-size: 29px;
text-align: center;
color: #007FC0;
text-transform: uppercase;
font-style: italic;
font-weight: bold;
}
.hr-rule{
position: absolute;
border: 7px solid #FF9900;
width: 400px;
}
But rather than have the above image, I have this Instead.
And using it inside the code I have this
import React from 'react';
import './app-styles.css';
import Vector from './Vector.png'
import ie_logo from './ie_logo.png';
import {Link} from 'react-router-dom';
function HomePage() {
return (
<div className="App">
<header className="header">
<img src={Vector} style={{margin:7, flexDirection:'column', alignItems: 'center'}} alt="Vector" />
<img src={ie_logo} style={{margin:7, flexDirection: 'row', width:114, height:25}} alt="ie_logo" />
<p className="needhelpText">REGISTERED? LOGIN</p>
</header>
<form>
<div className="InstructionText">
payment
</div>
<div className="hr-rule">
</div>
</form>
<footer className="footer">
Privacy Policy |
Do Not Sell My Personal Information |
Advertising Guidelines |
Site Map
<div className="copyrightText">
© Copyright 2021 | Lucas Tech | All Rights Reserved
</div>
<div className="footerLogo">
<img src={ie_logo} alt="ie_logo" />
</div>
</footer>
</div>
);
}
export default HomePage;
This seems like a very complicated method. Why not use a pseudo-element?
.InstructionText {
margin-bottom: auto;
font-family: Arial, Helvetica, sans-serif;
font-size: 29px;
justify-content: center;
color: #007FC0;
text-transform: uppercase;
font-style: italic;
font-weight: bold;
display: flex;
}
.InstructionText:after {
content: "";
border-bottom: 7px solid #FF9900;
margin-bottom: 7px;
width: 200px; /* or whatever width you require */
}
<div class="InstructionText">
payment
</div>
The main reason being that div is a block element by default, thus it will stack on top of each others. We can achieve your goal by using flex, which put the 2 divs side-by-side:
HTML:
<form>
<div class="header-container">
<div class="InstructionText">
payment
</div>
<div class="hr-rule"></div>
</div>
</form>
CSS:
.header-container {
display: flex;
justify-content: center;
align-items: center;
}
.InstructionText{
margin-bottom: auto;
font-family: Arial, Helvetica, sans-serif;
font-size: 29px;
text-align: center;
color: #007FC0;
text-transform: uppercase;
font-style: italic;
font-weight: bold;
}
.hr-rule{
margin-left: 20px;
height: 14px;
background-color: #FF9900;
width: 400px;
}
For the thick line, instead of using border, it's more efficient and understandable to just make a div with the width and 14px height, which achieve the same thing.

text background new line padding issue

I am dealing with text blocks (background blocks over text) and face some issues with paddings on new line. The problem occurs when the browser(e.g. mobile) cuts the text into to two lines due to lack of width. text then looks like this:
I don't really know how to set a padding css on the end of the new lines, since it could break up anywhere of the sentence. You could say put a span on it with padding, but it is not fixed where the line will break down. It depends on the width. Any recommendations?
You could apply display: inline-block but that will turn the background color into an ugly box which doesn't look as nice as having an exact width background for each line. Unfortunately CSS doesn't let us target individual lines except for the first one.
If you don't mind getting a little "creative" (or hacky) you could wrap each word in its own element in the backend or using JavaScript and apply the background color to those elements. Adjust the parent's word-spacing accordingly to eliminate gaps.
.main {
font-family: sans-serif;
font-weight: bold;
background-color: #99c;
display: flex;
height: 400px;
flex-direction: row;
align-items: center;
}
.text-container {
max-width: 500px;
display: inline-block;
word-spacing: -15px;
position: relative;
padding-left: 20px;
overflow: hidden;
}
.text-container::before {
content: '';
background-color: black;
position: absolute;
top: 0;
left: 0;
width: 20px;
height: 100%;
z-index: 1;
}
span {
font-size: 36px;
line-height: 1.5em;
color: white;
background-color: black;
padding: 0.25em 0.5em 0.25em 0;
max-width: 360px;
}
<div class="main">
<div class="text-container">
<span>A</span> <span>Movie</span> <span>in</span> <span>the</span> <span>park:</span> <span>Kung</span> <span>Fu</span> <span>Panda</span>
</div>
</div>
You can use box-shadow for this issue and display inline:
<div class="text">
<span class="text-container">A Movie in the park: Kung Fu Panda</span>
</div>
And css:
.text > span {
display: inline;
box-shadow: 25px 0 0 black, -10px 0 0 black;
background-color: black;
color: white;
}
Try to add after "Park:" and before "Kung"
padding workded!!!
change width by console browser and see result:
h1{
background-color: #ff6a6a;
padding: 33px;
display: inline-block;
word-wrap: break-word;
width:300px
}
<h1>rert ert erttttttttttttttt 00000000000000000000 dfgdfgd dfgdfgdft ertert </h1>
Use <p> tag to wrap up the text and it apparently works demo
<div class="main">
<div class="text-container">
<p id="test">A Movie in the park: Kung Fu Panda</p>
</div>
</div>
css
.main {
font-family: sans-serif;
font-weight: bold;
background-color: #99c;
display: flex;
height: 400px;
flex-direction: row;
align-items: center;
}
.text-container {
max-width: 400px;
}
p {
font-size: 36px;
line-height: 2em;
color: white;
background-color: black;
padding: 0.5em;
max-width: 360px;
}

Unfixed Responsive design styling

Updated!!!
I've still facing the same error each time I view the page on landscape screen devices.
CSS:
f5 {
text-transform: uppercase;
color: #fff;
font-size: 30px;
font-weight: bold;
}
about.us
<div class="containerpreview">
<br>
<f5>Check out our products</f5>
<br>
<f6>and Experience no-frills delivery</f6>
<div style="margin-top:40px">
<div class="buttoneshop">Eshop</div>
</div>
</div>
is there a way to make the spacing in between closer? When I command out
text-transform: uppercase;
the spacing is fine.
Aside of that, is there a way to make an image inside src under href to be centered?
css
.images_1_of_4 img {
max-width: 100%;
<!-- height: 200px; -->
width: 200px;
align: middle;
}
.img {
display: block;
width: 100%;
max-width: 100%;
height: auto;
}
.grid_preview {
height: 200px;
}
shop.php
<div class="grid_1_of_4 images_1_of_4">
<div class="grid_preview">
<img src="..." alt="">
</div>
</div>
Try to change alignment text-align : justify; to text-align : left.
Or, if this is not what you like to do, letter-spacing is a CSS attibute to change space between charagcters, and word-spacing to change space between words
As other users suggested, consider forcing alignment on the left using text-align : left, you probably have text-align : justify; on a wrapper element or setted in another part of your css as depicted the example below.
https://jsfiddle.net/s5p9872t/
.f5 {
text-align : justify;
width: 250px;
}
.f5 {
text-transform: uppercase;
font-size: 30px;
font-weight: bold;
text-align: left;
}

Resources