List div won't become horizontal with flex using Tailwind CSS with ReactJS - html

I'm trying to create a header with the Title in the center, the logout button at the right, and a horizontal list menu at the bottom.
I'm using Tailwind CSS for styling, but the list won't become horizontal no matter what I throw at it.
import React from 'react'
function Header(props) {
return (
<section className="text-black bg-white">
{/* MAIN TEXT AND USER LOGIN/LOGOUT */}
<div className="flex items-center justify-center p-6">
<h1 className="text-6xl px-3 rounded-md shadow-lg py-1 bg-lmgray">
NEW STREET JOURNAL
</h1>
<div className="absolute right-20 mt-2 px-5 rounded-md shadow-lg py-1 bg-lmgray" >
<p>{props.name}</p>
<button className="border-2 border-solid border-black rounded-md ">Logout</button>
</div>
</div>
{/* NAVBAR */}
<div className="">
<ul>
<li>
Home
</li>
<li>
World
</li>
<li>
India
</li>
<li>
Politics
</li>
<li>
Economy
</li>
<li>
Markets
</li>
<li>
Opinion
</li>
<li>
Real Estate
</li>
</ul>
</div>
</section>
)
}
Header.defaultProps={
title: 'News Feed'
}
export default Header
Where am I going wrong?

Try applying inline display to all the list items, for example:
<li className="inline">
Home
</li>
Alternatively, you can use divs instead of unordered lists, and use flexbox in the parent div as such:
<div className="flex">
<div>
Home
</div>
<div>
World
</div>
<div>
India
</div>
<div>
Politics
</div>
<div>
Economy
</div>
<div>
Markets
</div>
<div>
Opinion
</div>
<div>
Real Estate
</div>
</div>
The second method might be better as it allows you to control the styling from one parent div rather than having to change it for each child.

Related

Using TailwindCSS to put logo in top left and menu in top right

I have managed to write some Tailwind CSS to put a logo in the top left hand corner of the screen, but now I cant seem to get a menu to render in the top right, this is what I have. Nothing I try seems to work. It just renders right next to the logo image
<div className="isolate">
<div className="px-6 pt-6 lg:px-8">
<div>
<nav
className="flex h-9 items-center justify-between"
aria-label="Global"
>
<div
className="flex lg:min-w-0 lg:flex-1"
aria-label="Global"
>
<a href="/" className="-m-1.5 p-1.5">
<span className="sr-only">This Company Name</span>
<img
className="h-8"
src="/this-company-logo.png"
alt="This Company Name"
/>
</a>
<ul>
<li>Home</li>
<li>Contact</li>
</ul>
</div>
</nav>
</div>
</div>
</div>
<div className="isolate">
<div className="px-6 pt-6 lg:px-8">
<nav className="flex items-center justify-between" aria-label="Global">
<div className="flex-1">
<a href="/" className="-m-1.5 p-1.5">
<span className="sr-only">This Company Name</span>
<img
className="h-8"
src="/this-company-logo.png"
alt="This Company Name"
/>
</a>
</div>
<div className="flex items-center">
<ul className="flex space-x-4">
<li>
Home
</li>
<li>
Contact
</li>
</ul>
</div>
</nav>
</div>
</div>
You have to just remove this tag
...
<div
className="flex lg:min-w-0 lg:flex-1"
aria-label="Global"
>
...
</div>
...

Different items height inside of div when using flexbox(TailwindCSS)

I am using Flex in tailwind in one my main div container to align the items inside of it horizontal
but somehow the items are of different sizes in the row the image link is below any fixes for it?
i have tried using height utility class but it just messes up the entire page.
[1]: https://i.stack.imgur.com/Yjs51.jpg
HOME
ORDERS
MENU CARD
FAQs
ABOUT
Butter Chicken
If you haven't tried butter chicken, you don't know what you'r missing.
</div>
</div>
</a>
<a href="butterchicken.html">
<div class="max-w-sm rounded overflow-hidden shadow-lg justify-center">
<img class= "w-full" src="images/download (1).jpg" alt="malai-chicken">
<div class="px-6 py-8">
<div class="font-extrabold text-xl pb-3">Malai Chicken</div>
<div>
<p class=" font-serif text-base mb-3">Clean as white and appetizing.</p>
</div>
</div>
</div>
</a>
</a>
<a href="butterchicken.html">
<div class="max-w-sm rounded overflow-hidden shadow-lg justify-center">
<img class= "w-full" src="images/download (2).jpg" alt="Shahi Paneer">
<div class="px-6 py-8">
<div class="font-extrabold text-xl pb-3">Shahi Paneer</div>
<div>
<p class=" font-serif text-base mb-3">First Pick of Royales.</p>
</div>
</div>
</div>
</a>
</div>

My html navbar not working well in phone screen

Hey I am using tailwind css to complete my website. My navbar doesn't gives me full screen view in phone screen. Please help!!!
ScreenShot of bug Click here
You can check original site hosted on github - Website Link
HTML and Tailwind-CSS :
<nav class="flex justify-between bg-blue-500 w-full">
<div class="ncrt-sol mx-48 my-6">
<span class="text-white font-bold text-xl cursor-default">NCERT Solutions</span>
</div>
<div class="links">
<ul class="flex mx-40 my-6">
<li>Home</li>
<li>Solutions</li>
<li>Contact</li>
</ul>
</div>
</nav>
I tried width-full by using w-full class but it is still not working...
Try with class w-screen which will compile to 100%vw
Edit:
The margin of classes ncrt-sol and flex class is too high for mobile devices.
So this is causing the trouble . So instead of mx-40 change it to mx-4
So the final code is :
<nav class="flex justify-between bg-blue-500 w-full">
<div class="ncrt-sol mx-4 my-6">
<span class="text-white font-bold text-xl cursor-default">NCERT Solutions</span>
</div>
<div class="links">
<ul class="flex mx-4 my-6">
<li>Home</li>
<li>Solutions</li>
<li>Contact</li>
</ul>
</div>
</nav>
And change the margin likewise and use breakpoints for larger screen like md: lg: and the like.
Hope it helps!
The margin left and right of the .ncrt-sol div and .links div are too big for mobile screen and causing it to overflow the body element. Try to use a smaller value for mobile devices.

Link using id tag hides Title content of a div

So i have been working on a project. But Clicking on Footer link hides the title portion of the id like the 2nd image . is there any way to show it like the 3rd pic . Tried adding padding top to the id element still not working. Showing this
Want to show like this
My Footer Code
<!-- Tailwind -->
<link href="https://unpkg.com/tailwindcss#^2/dist/tailwind.min.css" rel="stylesheet">
<!-- Body -->
<div class="w-full px-4 md:w-1/3">
<h2 class="mb-3 text-2xl tracking-widest title-font text-textC font-futuraB">
TOP SERVICES</h2>
<ul class="mb-10 list-none font-futuraL">
<li class="py-0.5">
Brand strategy
</li>
<li class="py-0.5">
Identity Design
</li>
<li class="py-0.5">
Marketing & Development
</li>
<li class="py-0.5">
<a rel="noopener noreferrer" href="http://ignition.brandheft.com/" class="text-textAltC hover:text-accentC">Printing Services</a>
</li>
</ul>
</div>
Div Element having the issue
<!-- Tailwind -->
<link href="https://unpkg.com/tailwindcss#^2/dist/tailwind.min.css" rel="stylesheet">
<!-- Body -->
<div class="flex flex-wrap justify-center mx-auto lg:w-4/5 service_container_1" id="strategy">
<div class="order-first object-cover object-center rounded lg:w-1/2">
<img class="w-full h-72 lg:h-auto service_img_1" src="https://via.placeholder.com/300.jpg">
</div>
<div class="w-full my-auto mb-6 text-center lg:w-1/2 lg:pr-10 lg:py-6 lg:mb-0 font-futuraM lg:text-left">
<h1 class="pt-12 mb-4 text-5xl font-medium text-textC">Brand Strategy</h1>
<p class="mb-4 text-base leading-relaxed lg:text-lg text-textAltC first-letter:text-accentC first-letter:text-xl lg:first-letter:text-2xl font-futuraL">Whether you want to be remembered by your customers, connect with your audience, or increase the prices of your products by showing them the value, you need to differentiate yourself from your competitors. Differentiating doesn't always mean providing
a totally different product or service. Differentiating means adding a little something extra that'll make a huge impact. That naturally comes from your vision but you need to mine it using a proper brand strategy. A brand strategy encompasses your
company's mission, promises to your customers, and a plan to communicate the same to your audience. Here's how we can help you draft a successful brand strategy.</p>
<div class="space-y-2">
<div class="flex flex-col justify-between space-y-2 lg:space-y-0 lg:flex-row">
<span class="text-accentC">Brand purpose</span>
<span class="text-accentC">Target audience</span>
</div>
<div class="flex flex-col justify-between space-y-2 lg:space-y-0 lg:flex-row">
<span class="text-accentC">Brand attributes</span>
<span class="text-accentC">Brand book</span>
</div>
<div class="flex flex-col justify-between space-y-2 lg:space-y-0 lg:flex-row">
<span class="text-accentC">Brand mission statement</span>
<span class="text-accentC">Brand voice</span>
</div>
<div class="flex flex-col justify-between space-y-2 lg:space-y-0 lg:flex-row">
<span class="text-accentC">Brand personality</span>
<span class="text-accentC">Brand kit</span>
</div>
</div>
<div class="flex mt-10">
Get a Quote
</div>
</div>
</div>
LIVE WEBSITE

Why Footer is floating in tailwind css

I am using the tailwind CSS footer in my NextJS project. I am displaying fetched data. The footer is floating only when there are less data. I created a footer file in my pages and imported it into my _app.js file. I tried the absolute and fixed position. But it is not working. How do I keep my footer to the bottom?
<div className="relative mt-16 bg-gray-900">
<div className="px-4 pt-12 mx-auto sm:max-w-xl md:max-w-full lg:max-w-screen-xl md:px-24 lg:px-8">
<div className="flex flex-col-reverse justify-between pt-5 pb-10 border-t lg:flex-row">
<p className="text-base text-white-100">
© Copyright 2020. All rights reserved.
</p>
<ul className="flex flex-col mb-3 space-y-2 lg:mb-0 sm:space-y-0 sm:space-x-5 sm:flex-row">
<li>
<Link href="/Privacy">
<a className="text-sm tracking-wide font-medium text-white-100 transition-colors duration-300 hover:text-indigo-400">
Privacy Policy
</a>
</Link>
</li>
<li>
<a href="https://twitter.com/" target="_blank" rel="noreferrer noopener" className="text-sm tracking-wide font-medium text-white-100 transition-colors duration-300 hover:text-indigo-400">
Contact
</a>
</li>
</ul>
</div>
</div>
</div>
You could set a minimum height based on 100vh minus the height of the footer to the main content container.
<main class="min-h-[calc(100vh-210px)]">Main Content</main>
<footer class="h-[210px] bg-gray-900">
<!-- Your footer content -->
</footer>
Try it on TailwindCSS playground.