Customizing css file to display icon - html

I've been trying to customise an icon to show a logo in my header, but I don't know how to set up correctly my css file for this. I'm using Bootstrap, and the logo is stored in my static folder: /static/img/logo.jpg
First of, my code loads the bootstrap css file first, then my custom css file.
Then my html file references this:
...
<div class="page-header" >
<div class="container">
<h1><i class="icon-logo"></i></h1>
...
My css file so far contains this:
...
.page-header {
height: 60px;
margin-top: 0px;
background: red;
color: black;
font-size: 15px;
-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
z-index: 11;
}
.container {
width: 100;
height: 100;
}
.container h1 {
display: inline-block;
position: relative;
top: 0;
color: white;
font-size: 20px;
line-height: 20px;
font-weight: normal;
}
a {
position: center;
color: white;
text-decoration: none;
}
a:hover {
color: white;
text-decoration: underline;
}
...
What should I add to the css file to customise and display the logo?

I don't understand what exactly you wan't to do.
If you want the style the icon, just apply your CSS to that : .page-header .container h1 a i
But I think you wan't to replace the icon, so if you wan't to display your logo, and then style it, you could set your html like that :
<div class="page-header" >
<div class="container">
<h1><a href="https://mywebsite.com"><img src="/static/img/logo.jpg" alt"logo">
</a></h1>
</div>
</div>
And then apply your style to .page-header .container h1 a img
And it should be fine.

Related

Why my :nth-child() selector is not working with ::before

I was trying use the ":nth-child()" in the css to not having to make a new class everytime I want to put an icon. But when I tried the code was repeating the first icon. What do I did wrong?
#font-face {
font-family: 'icon';
src: url(assets/font/icon.ttf);
}
body {
background-color: #1D232A;
font-family: 'Open Sans', 'icon', sans-serif;
color: #FFFFFF;
}
.header-mobile {
display: flex;
justify-content: space-between;
align-items: center;
background-color: #15191C;
padding: 8px 16px;
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.16);
}
.header-mobile__button i::before {
display: block;
content: "\e904";
}
.header-mobile__button i:nth-child(2)::before {
content: "\e906";
}
.header-mobile__img {
width: 40px;
}
<body>
<header class="header-mobile">
<button class="header-mobile__button"><i></i></button>
<img src="assets/img/logo.svg" alt="Logo H2C" class="header-mobile__img">
<button class="header-mobile__button"><i></i></button>
</header>
</body>
i:nth-child(2) doesn't match anything because the only <i> elements you have are the first (not the second) child of their respective buttons.

Why can't I style anchor elements?

This is all my code (the code seems very messy because I just started learning about 2/3 weeks ago). I cant seem to style the anchor elements. I even tried putting a class on them and it also doesn't works. I'm kinda new to this thing.
#import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&display=swap');
#import url('https://fonts.googleapis.com/css2?family=Merriweather:wght#700&display=swap');
#import url('https://fonts.googleapis.com/css2?family=Bree+Serif&display=swap');
#import url('https://fonts.googleapis.com/css2?family=Inter:wght#500&display=swap');
body {
height: 100%;
margin: 0;
padding: 0;
background: #bbb;
}
.ex-house {
padding: 0;
display: block;
margin: 0 auto;
max-height: 100%;
max-width: 100%;
opacity: 0.8;
}
.house-dh {
position: absolute;
top: -20%;
left: 2%;
padding: 0px;
margin: 0px;
color: rgb(255, 255, 255);
font-family: 'Bree serif';
font-size: 125px;
text-align: center;
text-shadow: 2px 2px 3px rgba(255, 255, 255, 0.1);
}
.about-gnco1 {
position: absolute;
color: rgb(255, 255, 255);
font-family: 'Inter';
font-size: 35px;
text-align: left;
margin: 0px;
padding: 0px;
left: 2%;
top: 20%;
text-shadow: 2px 2px 3px rgba(255, 255, 255, 0.1);
}
/* this is my code for the style element i think i did it right but when i run it. the a href element dosent change */
.front-button {
font-family: 'Bebas Neue';
font-size: 20px;
color: white;
text-shadow: 2px 2px 3px rgba(255, 255, 255, 0.1);
}
.front-button a {
margin: 0 20px;
}
<body>
<div class="front">
<img class="ex-house" src="https://via.placeholder.com/80" alt="dreamhouse">
<div class="house-dh">
<p>grandnew.co</p>
</div>
<div class="about-gnco">
<p class="about-gnco1">Is here to help you<br> build your own<br> Dream House.</p>
</div>
</div>
</div>
<div class="front-button">
CUSTOMIZE
DESIGNS
PLANS
ABOUT US
</div>
</body>
if you mean underline of link for that you can use the method text-decoration for examplea{text-decoration:none} this code will remove any decorations of a tag so if you wanna use this function for all a tags you will write a{text-decoration:none} so if you wanna set decoration of specific tag you can give a class on the tag before you can change something example
HTML
go to stackoverflow
<a class="a-tag" href="https://stackoverflow.com">go to stackoverflow</a>
CSS
a{ //for all <a> tags
text-decoration:none
}
.a-tag{ // only for tag who have the a-tag class
text-decoration:none
color:black;
}
This works for me. The style of the text in the '.front-button a', not in '.front-button'
.front-button a {
margin: 0 20px;
font-family: 'Bebas Neue';
font-size: 20px;
color: red;
text-shadow: 2px 2px 3px rgba(241, 238, 53, 0.5);
}
link style
More about link styles:
https://www.w3schools.com/css/css_link.asp
How do I change link style in CSS?

Website button underline won't go away, how can I fix this?

I'm quite new to web development and am making a website for myself. I've come across an issue regarding buttons on my website where the text underline for a button doesn't go away. For some reason, even after applying text-decoration: none !important; it's still there.
A bit of background on what I'm trying to do
I've added two buttons that look the same, but they link to different things. This is because I want the links to change on mobile. In the CSS media query I've specified which button displays on mobile devices. The original buttons are fine, but the ones I want to use on mobile devices have a purple underline for some reason.
I'd love some help to have this sorted out because the underline makes the button look a bit odd when displayed on mobile. I've attached some images and code for one of the buttons below.
Images:
Code:
This is the HTML for a pair of the buttons:
<div class="cont3_left_wrapper">
<h2 class="hd2_1">Header Text</h2>
<p>
Body Text
</p>
<a href="#/" id="header_button_3">
<button type="button" class="btn_chat">Let's Chat</button>
</a>
<a href="#/" id="header_button_3_mob">
<button type="button" class="btn_chat_mob" onClick="location.href='contact.html'">Let's Chat</button>
</a>
</div>
This is the CSS for the buttons:
.btn_chat {
padding: 13px 0 11px 0;
background-color: #E84855;
border-radius: 4px;
border: none;
text-decoration: none;
text-align: center;
font-size: 24px;
font-weight: 700;
color: white;
box-shadow: 0px 2.0407px 20.407px rgba(0, 0, 0, 0.25);
margin-top: 35px;
width: 270px;
}
.btn_chat_mob {
display: none;
padding: 13px 0 11px 0;
background-color: #E84855;
border-radius: 4px;
border: none;
text-align: center;
font-size: 24px;
font-weight: 700;
color: white;
box-shadow: 0px 2.0407px 20.407px rgba(0, 0, 0, 0.25);
margin-top: 35px;
width: 270px;
}
#media screen and (max-width: 480px) {
.btn_chat {
display: none;
width: 100%;
}
.btn_chat_mob {
display: block;
width: 100%;
text-decoration: none !important;
}
}
.btn_chat_mob {
display: inline-block;
width: 100%;
}
Since Your button is inside [a tag] and it has underlined as default CSS you should apply following CSS to [a tag] also it should work..
a {
text-decoration: none;
outline: none;
}
a:hover {
outline: none;
}
a:focus {
outline: none;
}

Is it possible to preserve toggles in Inline CSS or do some other trick to send collapsible sections in emails?

I have little experience in HTML so I apologize if this question has already been answered.
I want to send an email that has a few very long sections so I want them to be collapsible. I don't know much html/css but I was able to put something together that collapses the sections. However, whenever I convert it to inline css, I can no longer view the sections that are displayed.
I am open to other ideas on collapseable sections, however, I cannot use regular css, anything that falls under , any javascript, and anything in external documents.
Sample code below
<head>
<style>
body {
font-family: "Open Sans", Arial;
background: #CCC;
}
main {
background: #EEE;
width: auto;
margin: 20px auto;
padding: 10px 0;
box-shadow: 0 3px 5px rgba(0, 0, 0, 0.3);
}
h2 {
text-align: center;
}
p {
font-size: 16px;
}
input {
display: none;
visibility: hidden;
}
label {
display: block;
padding: 0.5em;
text-align: center;
border-bottom: 1px solid #CCC;
color: #444;
}
label:hover {
color: #000;
}
label::before {
font-family: Consolas, monaco, monospace;
font-weight: bold;
font-size: 15px;
content: "+";
vertical-align: text-top;
display: inline-block;
width: 20px;
height: 20px;
margin-right: 3px;
background: radial-gradient(ellipse at center, #CCC 50%, transparent 50%);
}
#expand0 {
height: 0px;
overflow: hidden;
transition: height 0.5s;
background: #FFF;
color: #000;
}
section {
padding: 0 20px;
}
#toggle0:checked~#expand0 {
height: 85px;
}
#toggle0:checked~label::before {
content: "-";
}
</style>
</head>
<main>
<input id="toggle0" type="checkbox" checked>
<label for="toggle0">Example</label>
<div id="expand0">
<section>
<p>Hello There</p>
<p>General Kenobi</p>
</section>
</div>
</main>
Inline of Example
<main style="background-color:#EEE;background-image:none;background-repeat:repeat;background-position:top left;background-attachment:scroll;width:auto;margin-top:20px;margin-bottom:20px;margin-right:auto;margin-left:auto;padding-top:10px;padding-bottom:10px;padding-right:0;padding-left:0;box-shadow:0 3px 5px rgba(0, 0, 0, 0.3);" >
<input id="toggle0" type="checkbox" checked style="display:none;visibility:hidden;" >
<label for="toggle0" style="display:block;padding-top:0.5em;padding-bottom:0.5em;padding-right:0.5em;padding-left:0.5em;text-align:center;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#CCC;color:#444;" >Example</label>
<div id="expand0" style="height:0px;overflow:hidden;transition:height 0.5s;background-color:#FFF;background-image:none;background-repeat:repeat;background-position:top left;background-attachment:scroll;color:#000;" >
<section style="padding-top:0;padding-bottom:0;padding-right:20px;padding-left:20px;" >
<p style="font-size:16px;" >Hello There</p>
<p style="font-size:16px;" >General Kenobi</p>
</section>
</div>
</main>
Your example doesn't work because you can't specify inline styles for checked status.
You have to use css for that.
On another note: You say that you want to use this in an email, I don't think any email client would render your collapsible content.
So to answer your question: You have to use CSS (file or tag) for this type of behaviour, it's not possible with inline CSS alone. If you want to send this via email it would be better to dismiss these collapsible elements altogether and maybe reduce the amount of stuff you send out in an email.

CSS Tooltip has different position in different browsers. How can I account for this?

I have adjusted my bottom attribute to display how I want it in Firefox, but the spacing is all warped in Chrome and Safari. Is there a way to sett a different "top" attribute for each browser?
HTML
<a class="tooltip" href="#"> <!-- this tag activates my tool tip -->
<div class="handsevent" > <!-- this div contains everything that activates the tool tip when hovered over-->
<div class="handswrapper">
<div class="handshour" >
<h3>8:00am-noon</h3>
</div>
<div class="handsspeaker">
<h3>Speaker 3</h3>
</div>
</div>
<div class="handstitle">
<p>Description</p>
</div>
</div>
<span class="classic"> <!-- this span contains everything that pops up in the tool tip -->
<h3>Title Bar</h3>
<br />lots of descriptive text
</span>
</a>
CSS
/* HOVER WINDOW */
.tooltip {
color: #000000; outline: none; font-style:bold;
cursor: help; text-decoration: none;
position: relative;
}
.tooltip span {
margin-left: -999em;
position: absolute;
}
.tooltip:hover span {
border-radius: 30px 30px; -moz-border-radius: 30px; -webkit-border-radius: 30px;
box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.1); -webkit-box-shadow: 5px 5px rgba(0, 0, 0, 0.1); -moz-box-shadow: 5px 5px rgba(0, 0, 0, 0.1);
font-family: Arial, Tahoma, Helvetica, sans-serif;
position: auto; left: 1em; top: 2em; z-index: 99; <!-- the 'top' attribute on this line is where I have been adjusting the display position it affects the position differently in different browsers -->
margin-left: 0; width: 700px; margin-top:-10px;
}
.tooltip:hover img {
border: 0; margin: -30px 0 0 90px;
float: right; position:fixed;
z-index: 99;
}
.tooltip:hover em {
font-family: Arial, Tahoma, Helvetica, sans-serif; font-size:14px; font-weight: bold; color:005DA4;
display: block; padding: -0.2em 0 0.6em 0;
}
.classic { padding: 0.8em 1em; }
* html a:hover { background: transparent; }
.classic {background: #ffffff; border: 1px solid #ffffff; }
I have tried pixels, em, and percentage. None of these have been consistent. Are there browser specific settings I could use?
here is a demo link for reference.
Using a CSS Reset will help to eliminate differences between browsers.
I switch the top attribute in ".tooltip:hover span" to "auto" and that seems to be working.