I am building an ubereats copy with react.
To identically copy the style in key components (such as the navbar and the sidebar) I need to use custom css.
I don't need to make an exact copy and I want to save up time, that's when i decided to use React-bootstrap aswell.
To work with react bootstrap I need to have this line in my index.js or App.js, I have it on my index.js :
import 'bootstrap/dist/css/bootstrap.min.css';
To work with my custom css I have to import those, I have a custom css for my navbar and my sidebar and I am importing the css in the component, in the Navbar:
import './MainNav.css';
I found that if I comment out the line where I import React-bootstrap and run npm start my navbar is displayed according to my css, and, obviously, React-my bootstrap components are unstyled:
Page without React-bootstrap min css imported
And if i don't comment out the line where I import React-bootstrap and run npm start my navbar elements are all around the place and I can't manage to restyle them back in the desired position but, obviously my React-bootstrap components are styled accordingly:
Page with React-bootstrap min css imported
I haven't been able to find a post related to this problem, how can I fix the compatibility problem?
I have tried with importing import 'bootstrap/dist/css/bootstrap.min.css'; only in those components it is needed but it is all the same.
I installed React-bootstrap via npm and have this versions:
"react": "^17.0.0",
"react-bootstrap": "^1.4.0",
I also tried to include bootstrap from CDN by adding this line in my index.html instead of using the import in index.js but i had the same issue:
<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk"
crossorigin="anonymous"
/>
Send help
EDIT: I am including MainNav.css upon request.
#import url(//db.onlinewebfonts.com/c/11469c307f0de6481e3a04cc5d54ae93?family=Uber+Move+Text);
:root {
--font-family: sans-serif;
font-size: 16px;
--color-green: #06c167;
--color-grey: #eee;
--color-greyDarker: #545454;
}
* {
box-sizing: border-box;
}
#font-face {
font-family: "Uber Move Text";
src: url("//db.onlinewebfonts.com/t/11469c307f0de6481e3a04cc5d54ae93.eot");
src: url("//db.onlinewebfonts.com/t/11469c307f0de6481e3a04cc5d54ae93.eot?#iefix") format("embedded-opentype"), url("//db.onlinewebfonts.com/t/11469c307f0de6481e3a04cc5d54ae93.woff2") format("woff2"), url("//db.onlinewebfonts.com/t/11469c307f0de6481e3a04cc5d54ae93.woff") format("woff"), url("//db.onlinewebfonts.com/t/11469c307f0de6481e3a04cc5d54ae93.ttf") format("truetype"), url("//db.onlinewebfonts.com/t/11469c307f0de6481e3a04cc5d54ae93.svg#Uber Move Text") format("svg");
}
.smallText {
font-size: 0.7rem;
font-weight: 300;
font-family: "Uber Move Text";
}
.logo h1 span {
font-weight: 900;
color: var(--color-green);
font-size: 24px;
}
.general input {
font-family: sans-serif;
font-size: 15px;
font-weight: bold;
font-family: "Uber Move Text";
}
.logo {
font-weight: 300;
color: white;
font-family: "Uber Move Text";
}
.logo {
font-weight: 600;
color: var(--color-green);
font-family: "Uber Move Text";
}
input {
border: rgb(41, 41, 41);
border-width: 2px;
border-bottom-style: solid;
font-size: 16px;
padding: 10px;
background: rgb(240, 240, 240);
color: #000;
letter-spacing: 1px;
font-family: "Uber Move Text";
text-align: left;
width: 120%;
}
.navbarform {
margin-left: 50%;
margin-right: auto;
}
.tosidebar {
margin-right: 3%;
}
.navbar {
margin-bottom: 20px;
width: 100%;
}
.linkto{
text-decoration: none;
}
.linkto:visited { text-decoration: none; color:black; }
.linkto:hover { text-decoration: none; color:black; }
.linkto:focus { text-decoration: none; color:black; }
.linkto:hover, a:active { text-decoration: none; color:black }
.logout {
font-size: 20px;
}
Hard to tell without looking at your MainNav.css. So please include your file next time when you ask questions like this. Anyway, my guess is that the class selectors you have in your stylesheet are conflicting with classes defined by Bootstrap.
Related
I've watched some videos and copied what they did but it's not working. I have my file in the same folder as my documents. Ugh, the site wants me to add more "details" or it won't let me post. I had my html and my css pages separated but it put them together. If you know how feel free to break them apart.
.float-img {
float: left;
margin-right: 10px;
margin-left: 5px;
margin-bottom: 0px;
margin-top: 10px;
padding: 2px;
border: none;
}
.potato {
margin-left: 250px;
margin-top: 40px;
margin-right: 20px;
line-height: 38px;
font-family: 'lazyspringday';
}
.p1 {
font-family: 'lazyspringday';
}
body {
margin: 0;
padding: 0;
font-family: 'lazyspringday', serif;
}
#font-face {
font-family: "lazyspringday";
src: url('lazyspringday.ttf') format:('truetypefont');
}
.nav {
background-color: #ffb6c1;
color: #ffffff list-style: none;
text-align: center;
padding: 20px 0 20px 0;
}
.nav>li {
display: inline-block;
padding-right: 50px;
font-size: 16px;
}
.nav>li>a {
text-decoration: none;
color: #ffffff
}
.nav>li>a:hover {
color: #C0C0C0
}
.banner {
width: 100;
display: block;
}
.banner>.bannerimage {
width: 100;
height: 100;
display: block;
}
ul.nav {
margin: 0;
}
div.left {
width: 50%;
padding: 0 0 0 5%;
margin-right: 5px;
margin-top: 10px;
float: left
}
div.right {
width: 50%;
padding: 0 5% 0 0;
float: right
}
p {
padding-top: 25px;
text-align: left;
}
.potato {
color: #00b8e6;
font-size: 15px;
font-family: 'lazyspringday';
font-weight: 100;
}
<div class="header">
<img class="banner-image" src="ccc.png" width="100%" height="150px">
</div>
<ul class="nav">
<li>Home</li>
<li>About Us</li>
<li>Menu</li>
<li>Enter to Win</li>
<li>Merchandise</li>
<li>Events</li>
<li>Contact Us</li>
</ul>
<img src="british-shorthair-3055340_1920.jpg" width: "400" height="400" class="float-img">
<p class="potato">
Step into a magical world of cats at Cat Corner Cafe. Enjoy eating cute cat themed foods and drinks in a relaxing environment. Spend some quality time playing with some feline friends. Enjoy watching the cats have fun in an environment made just for them.
All cats will be adoptable and provided by the local shelter. Cat Corner Cafe will also have fun events like cat yoga, art with cats and game days. Come by yourself, with your meetup group or have your next birthday party here! We look forward to seeing
you. To be alerted when we open please sign up with your email on our homepage.
</p>
first of all define #font face on the top and remove ":" from format and rename turetypefont to truetype
#font-face {
font-family: "lazyspringday";
src: url('lazyspringday.ttf') format('truetype');
}
Hope this will help
first and foremost, put your fonts in fonts folder seperately and css stylesheet in css folder, then include/import fonts in your css at top like this.
#font-face {
font-family: 'lazyspringday';
src: url('../fonts/lazyspringday.eot');
src: url('../fonts/lazyspringday.eot?#iefix') format('embedded-opentype'),
url('../fonts/lazyspringday.woff2') format('woff2'),
url('../fonts/lazyspringday.woff') format('woff'),
url('../fonts/lazyspringday.ttf') format('truetype'),
font-weight: normal;
font-style: normal;
}
we use woff and woff2 for using fonts in web.
you can also use web fonts generator to generate webfonts just uploading your .ttf file there.
In the head tag of your html file (index?) place something like this:
<link href="(your file location)" rel="stylesheet">
After importing the font you can do it in several different ways. I'd recommend you to use a body tag that would contain everything on that html file.
If you chose to use the body tag, simply add this line to your css file:
body {
font-family: 'Montserrat', serif;
}
Example:
Use Google Fonts. https://fonts.google.com
Then copy this code into the <head> of your HTML document.
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
Then use the following CSS rules to specify these families:
font-family: 'Roboto', sans-serif;
I'm new to SVG and have been putting numbers in text tags for a week or two with no issues. It seemed straightforward. Now, strangely, I'm having an issue in which, no matter what numbers I put in, there is a dip in the second number.
Here is a pic to show you what is happening. The number "63" is supposed to be all on the same plane with itself, though a bit below the "This Week" designation. Instead, the '3' is dipping down lower. Pic of my problem.
My code:
<div class = "chartbox">
<div class = "svgcontainer" >
<svg class = "chart" width="590" height="440" role="img">
<g class = "bigbox">
<text x="346" y = "35" class = "blurbhed">This Week </text>
<text x ="491" y ="44" class = "blurbdeck"><?php echo round($kms_for_table[0]);?></text><text x ="540" y ="48" class = "blurbkm"><?php echo "km";?></text>
</g>
</svg>
</div>
</div>
The CSS:
body { background-color: #1C1816;
font-family: Raleway, Gotham-Rounded, Arial , sans-serif;}
.blurbhed {
font-size: 1.5em;
font-weight: 600;
fill: #650a5d;
letter-spacing: .3px;
}
.blurbdeck {
font-size: 2.7em;
font-weight: 600;
fill: #08292e;
letter-spacing: .4px;
}
.blurbkm {
font-size: 1.3em;
font-weight: 600;
fill: #08292e;
letter-spacing: .4px;
}
.svgcontainer {
display: block;
position: relative;
border: 10px solid purple;
background-color: lightyellow;
margin-left: 10px;
height: 453px;
width: 630px;
margin-top: 0px;
margin-bottom: 20px;
text-align: center;
margin-right: 50px;
}
.chartbox {
display: block;
margin-left: auto;
margin-right: auto;
height: auto;
width: 800px;
margin-bottom: 10px;
padding-top: 20px;
}
The same problem happens wherever I move the text around the svg element. It occurs with a variety of fonts, and with different numbers. It happens whether I just have it echo the number or have it generated by the code from my model. I also tried making a completely new text element in a different spot, and the same weird dip in the second number occurs.
I'm sure this is really simple, but I've been fiddling with it far too long and am hoping someone can help me out. Thank you!
This is definitely down to the design of the font being used.."Raleway".
h1 {
font-family: 'Raleway', sans-serif;
font-size: 72px;
text-align: center;
}
h2 {
font-family: 'Open Sans', sans-serif;
font-size: 72px;
text-align: center;
}
* {
margin:0;
}
<link href='https://fonts.googleapis.com/css?family=Raleway' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<h1>0123456789</h1>
<h2>0123456789</h2>
I can only suggest using a different font..but you'd have to test each for the right look.
There's a proper solution for this that allows you to continue using Raleway:
You need to do two things:
Add CSS instructing the browser to use the lining-figures
Avoid pre-optimised font files (as served by Google Fonts.)
The CSS:
body {
font-variant-numeric: lining-nums;
font-feature-settings: "lnum";
}
Alternative CDN (Brick):
<link rel="stylesheet" href="//brick.a.ssl.fastly.net/Raleway:400">
The problem with Google Fonts is that it minimises font download size by removing 'unnecessary' glyphs and meta-data. In particular in this case, it removes the lining-nums variation of figures from Raleway. (You can try adding &subset=all to a Google Font URL to circumvent this, but this doesn't appear to be reliable.)
I have the following css that is used to make one link coloured but it applies to all of the links I have. Is there any way to stop this.
This is my css that is getting applied to the links:
a:visited {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 14px;
font-style: italic;
font-weight: bold;
color: #FFF;
text-decoration: none;
background-color: #F00;
display: block;
border-radius: 5px;
z-index:10;
}
a:link {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 14px;
font-style: italic;
font-weight: bold;
color: #FFF;
text-decoration: none;
background-color:#F00;
display: block;
border-radius: 5px;
z-index:10;
}
a:hover {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 14px;
font-style: italic;
font-weight: bold;
color: #CCC;
text-decoration: none;
background-color: #C00;
display: block;
border-radius: 5px;
z-index:10;
}
This is the link that it is suppose to get applied to:
<td>Food</td>
This is the link that I don’t want it to get applied to:
<td class="footer"><b>Top Attractions</b>
You could select your a tag by the href like this:
JSFiddle - DEMO
a[href="Food.html"] {
color: red;
}
Updated: DEMO (with your codes)
Working JSfiddle: demo
I gave the link you wanted to style a class and gave the class a style.
a.food :visited
instead of a:visited
Try this
HTML
<td><a href="Food.html" class="colored>Food</a></td>
CSS
.colored{
color:red;
}
One thing you could do, would be to give the tag an id/class and then refer to that in your css.
You could add a class to the link you want different and style it separately.
HTML:
<td class="footer"><b>Top Attractions</b>
CSS:
a.rides {...}
Apply a class to the links you want to effect:
<a href='food.html' class='apply_to_this'>Food</a>
Then in your CSS:
a:link.apply_to_this{
// your styles
}
You can add a class to the links you wan't to apply this rule, or you can use this rule :
a:not(.footer):link {...}
Rather than stopping it being applied to one link, you need to add a class to that link with additional CSS that overrides the styles you want to change, or (though this is bad practice...) use inline styles on that one link.
Proper solution:
In your CSS
.exception {put css here that will override the general link css, using !important to override it ifnecessary}
In your html
Content here
Quick and dirty solution
Content
Though this way will work, it is rightly frowned upon for accessibility issues.
You can just create a class and apply it to that link like mentioned above or you can just follow through your selectors to tell CSS to apply that link code to only a:links within those selectors like I've posted below:
#mainContainer #footer #etc #etc a:link {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 14px;
font-style: italic;
font-weight: bold;
color: #FFF;
text-decoration: none;
background-color:#F00;
display: block;
border-radius: 5px;
z-index:10;
}
PS - Inline styles are very bad practice. It adds tons of extra code that will reduce your rankings for Google, Yahoo, MSN, etc. Not to mention it makes code harder to read and more clunky.
Im trying to use a custom font using #font-face and for some reason its working on some places and not in others.
CSS
This works fine
#hero-header .title {
color: #fff;
padding-top: 225px;
font-size: 30px;
font-family: 'Populaire';
text-align: center;
font-size: 64px;
}
This doesn't
ul#reviews h2 {
font-size: 30px;
font-family: 'Populaire';
}
Notice the Hero area using a custom font but unable to use it further down the page, ie: the review titles.
Your CSS is:
#font-face {
font-family: 'Populaire';
src: url('font/Populaire.otf');
}
But, the font is actually in /beta/styles/css/fonts/Populaire.otf, please update your CSS to:
#font-face {
font-family: 'Populaire';
src: url('/beta/styles/css/fonts/Populaire.otf');
}
hello i have a question according css.
in my navigationbar i have 3 links. i use:
#p1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
line-height: 45px;
font-weight: bolder;
color: #999999;
text-decoration: none;
}
for that status that shows on which site the user is located.
if the user rolls over the other two links i have these:
#p2 {
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
line-height: 45px;
font-weight: bolder;
color: #ECECEC;
text-decoration: none;
}
#p2:hover {
font-weight: bolder;
color: #999999;
cursor:default;
}
#p2:active {
font-weight: lighter;
color: #999999;
}
okay, the problem is that i would like to change the color from p1 when the user hovers p2. meaning something like:
#p2:hover {
font-weight: bolder;
color: #999999;
cursor:default;
#p1 {
color: #f23;
}
}
is that possible?
thanks a lot.
the html:
<div id="nav">
<div id="link"><p1>link1</p1></div>
<div id="link"><p2>link2</p2></div>
<div id="link"><p2>link3</p2></div>
<div id="link"><div id="login"></div></div>
</div>
This can't be done with pure CSS.
What you can do is to use javascript & change color of #p1 on the hover event of #p2.
OR you may use less css to set color of #p1 to a variable & change the value of that variable in #p2:hover, though I have not tried this method. But again less css is not pure css, it uses javascript too.
With javascript (using jquery library), your code will be:
$("#p2").hover(function() {
$("#p1").css('color', '#f23');
});