I am having an issue with my hero. For some reason this is appearing: https://gyazo.com/08edee1edcd0469d50da4883498a7f0a
This is my html (using bootstrap 5) and CSS. I've not styled it to do that, so I have no idea.
I've tried removing outline and border and it has not worked.
.hero-btn {
background-color: rgba(0, 0, 0, 0.6);
color: whitesmoke;
width: 18rem;
height: 5rem;
margin: 15px;
border-radius: 25px;
font-size: larger;
}
.hero-btn:hover {
color: white;
text-transform: uppercase;
font-weight: bold;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.3/dist/css/bootstrap.min.css" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<div class="pt-3">
<h1 style="font-weight: 600;">West Yorkshire Roleplay</h1>
<br>
<h4>Welcome to West Yorkshire Roleplay!</h4>
</div>
<div class="mx-auto my-auto">
<a href="https://storm.westyorkshireroleplay.com/signup">
<button class="btn hero-btn">Apply Now</button>
</a>
<a href="https://storm.westyorkshireroleplay.com/communityinfo">
<button class="btn hero-btn">About Us</button>
</a>
</div>
<a href="#contact">
<img src="https://i.imgur.com/uvPeSwr.png" alt="" style="width:auto; height: 70px; position: relative; bottom: -45%;">
</a>
You have added <button> tag inside <a> tag which is wrong. The blue line is because of <a> shows hyper link style to text place inside it, in your case its assuming white space as text and thus showing blue dash.
As you have shared image for reference, it displays default css style for <button> tag.
Check if this css styling suits your need.
.hero-btn {
background-color: rgba(0, 0, 0, 0.6);
color: whitesmoke;
width: 18rem;
height: 5rem;
letter-spacing: normal;
word-spacing: normal;
line-height: 4;
text-align: center;
appearance: auto;
border-width: 2px;
border-style: outset;
border-color: buttonborder;
cursor: default;
box-sizing: border-box;
margin: 15px;
border-radius: 25px;
text-decoration: none;
font-size: larger;
}
.hero-btn:hover {
color: white;
text-transform: uppercase;
font-weight: bold;
}
<div class="pt-3">
<h1 style="font-weight: 600;">West Yorkshire Roleplay</h1>
<br>
<h4>Welcome to West Yorkshire Roleplay!</h4>
</div>
<div class="mx-auto my-auto">
<a class="btn hero-btn" href="https://storm.westyorkshireroleplay.com/signup">
Apply Now
</a>
<a class="btn hero-btn" href="https://storm.westyorkshireroleplay.com/communityinfo">
About Us
</a>
</div>
<a href="#contact">
<img src="https://i.imgur.com/uvPeSwr.png" alt="" style="width:auto; height: 70px; position: relative; bottom: -45%;">
</a>
What you're seeing is whitespace styled as a link due to your faulty HTML. Buttons have no business inside anchors. They each have a particular purpose (buttons for action, anchors for navigation) and should never be used together. If you want anchors styled as buttons, use the appropriate button classes. If you want buttons styled as text links, do the same.
Other advice...
Don't use inline styles. It's a pain for you and it's a pain for us and it's a pain for everyone who comes after. Use Bootstrap classes where you can (border radius, font size, font weight), and use custom classes with CSS everywhere else.
And don't use line breaks for spacing. That's not their purpose. Use margin or padding.
The my-auto class probably isn't doing what you think it's doing. Look into flexbox if you want to center things vertically. Of course you have to provide space in which to center.
Always strive for the simplest implementation possible. That means knowing what your library offers, and applying styling directly to elements when possible, as opposed to container elements that aren't necessary. Recognize that almost everything has relative position by default.
Finally, keep visual effects like hover changes subtle. This isn't Nintendo World. You don't want to nauseate your users with obnoxious behavior. A soft shadow or slight movement with animation to be easier on the eyes is often best.
body {
background: #ddd !important;
}
.hero-btn {
background-color: rgba(0, 0, 0, 0.6);
color: whitesmoke;
width: 18rem;
height: 5rem;
margin: 15px;
border-radius: 25px;
font-size: larger;
}
.hero-btn:hover {
color: white;
text-transform: uppercase;
font-weight: bold;
}
.fw-600 {
font-weight: 600;
}
.down-img {
width: auto;
height: 70px;
bottom: -45%;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.3/dist/css/bootstrap.min.css" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<h1 class="pt-3 pb-2 fw-600">West Yorkshire Roleplay</h1>
<h4>Welcome to West Yorkshire Roleplay!</h4>
<div class="mx-auto my-auto">
Apply Now
About Us
</div>
<a href="#contact">
<img src="https://i.imgur.com/uvPeSwr.png" class="down-img" alt="">
</a>
Related
I put the web into the IOS app as a webview.
When I use the <detail> tag of html 5, I want to change it's display to flex not block,in web it can work but it cannot work on the phone
This is my code, is there any mistake?
details summary::-webkit-details-marker {
display: none;
}
details{
width:100%;
}
details summary {
width: 100%;
/* padding: 0.5rem 0; */
border-bottom: 1px solid #dddddd;
position: relative;
cursor: pointer;
font-size: 1.25rem;
font-weight: 300;
list-style: none;
float:left;
}
details summary:after {
content: "click me";
color: black;
right: 0;
transform-origin: center;
transition: 200ms linear;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet"/>
<details style="display: flex; ">
<summary class="d-flex">
<div class="mr-3 w-75">
<p class="font-weight-bold mb-0">title</p>
</div>
<div class="mr-3 w-75">
<p class="font-weight-bold mb-0">date</p>
<span class="t-12">time</span>
</div>
</summary>
<p>
<pre class="d-inline">content</pre>
</p>
</details>
This issue is documented here: https://github.com/philipwalton/flexbugs#flexbug-9
The following workaround was proposed there:
The simple solution to this problem is to use a wrapper element that can be a flex container (like a ) directly inside of the element that can't. Demos 9.1.b and 9.2.b show workaround for the and elements, respectively.
In your case you should wrap your elements that should be displayed as flex in a wrapper element like a div.
I also faced a similar issue: the flex properties were not working with the summary tags in a WebView, otherwise working on a normal browser. The only workaround I found was to recreate the details-summary tag functionality with javascript by changing the display property.
document.querySelector('.summary').addEventListener('click', function() {
let collapsible = this.nextElementSibling
collapsible.classList.toggle('d-block')
})
section {
width: 100%;
}
.collapsible {
display: none;
overflow: hidden;
}
.summary {
width: 100%;
/* padding: 0.5rem 0; */
border-bottom: 1px solid #dddddd;
position: relative;
cursor: pointer;
font-size: 1.25rem;
font-weight: 300;
list-style: none;
}
.summary::after {
content: "click me";
color: black;
right: 0;
transform-origin: center;
transition: 200ms linear;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet" />
<section>
<div class="d-flex summary">
<div class="mr-3 w-75">
<p class="font-weight-bold mb-0">title</p>
</div>
<div class="mr-3 w-75">
<p class="font-weight-bold mb-0">date</p>
<span class="t-12">time</span>
</div>
</div>
<div class="collapsible">
<pre class="d-inline">content</pre>
</div>
</section>
i have meet same issue.when i use flex in ssummary tag.i think a good way is not to use flex instead of using other css layout ways.
position:absolute;
use trandition css to manage our child
I have a list of users, with two inline elements: a "contact me" button ('a' element with a fontawesome icon) and a tag showing the type of user (span element).
Not all users have a tag, and whenever there is a tag, the 'a' element is giving to the icon more width than it needs. This is how it looks like:
As you can see, the bottom one fits correctly, while the blue space of the top one is bigger on the right. They have the exact same classes and attributes (this is generated from a loop, so it's the same code).
This is the HTML code for the link+span:
.item-title {
margin-bottom: 10px;
}
.item-btn-contact {
margin-left: 10px;
padding: 3px 10px;
border-radius: 5px;
background-color: #1b95e0;
font-size: 80%;
color: #fff;
text-decoration: none;
}
.item-type-tag {
margin-left: 10px;
padding: 3px 5px;
border-radius: 5px;
background-color: #dedede;
font-weight: bold;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css" rel="stylesheet"/>
<div class="item-title">
xxxx
<a href="" class="item-btn-contact" title="Contattami">
<i class="fas fa-envelope"></i>
</a>
<span class="item-type-tag">Allenatore</span>
</div>
<div class="item-title">
xxxx
<a href="" class="item-btn-contact" title="Contattami">
<i class="fas fa-envelope"></i>
</a>
</div>
I tried checking if there was any difference in the cumputed styles of the two elements through javascript (maybe there was a ":last-child" selector somewhere), but their maps looks exactly the same (checked using getComputedStyle on both elements).
Whenever I change the span element display property to block, flex, or other not-inline options, the other element resize itself in the correct way.
The only option I found is to change the icon width to .8em (currently 1em), and then add a last-child selector to resize it correctly to 1em when there is no span on the right, but it's not a real solution...
Could anyone help me figure out why, or at least how to fix it?
Set the display on item-btn-contact to inline-block. Seems like the default display of a (inline) is messing with the sizing.
.item-title {
margin-bottom: 10px;
}
.item-btn-contact {
margin-left: 10px;
padding: 3px 10px;
border-radius: 5px;
background-color: #1b95e0;
font-size: 80%;
color: #fff;
text-decoration: none;
display: inline-block;
}
.item-type-tag {
margin-left: 10px;
padding: 3px 5px;
border-radius: 5px;
background-color: #dedede;
font-weight: bold;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css" rel="stylesheet"/>
<div class="item-title">
xxxx
<a href="" class="item-btn-contact" title="Contattami">
<i class="fas fa-envelope"></i>
</a>
<span class="item-type-tag">Allenatore</span>
</div>
<div class="item-title">
xxxx
<a href="" class="item-btn-contact" title="Contattami">
<i class="fas fa-envelope"></i>
</a>
</div>
I have two buttons, one on the left, and one on the right. For some reason when I zoom in, I see my main button, and a bigger one behind it. They both change color when I hover, and are both clickable, but only the main one at the front links me where I want to go. I want the mysterious appearing button behind the main one to disappear. I think it may have something to do with the width, but it is set at 180px, and the height is auto.
HTML
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="setupstylesheet.css">
<title>Setting up Your Website Folders</title>
</head>
<body>
<div id="body">
<img src="Images/web-development-banner.jpg" width="100%" height="400">
<h1 class="webheading">Website Developement</h1>
<div class="margin">
<div class="shading">
<h1>2. Setting Up Your Website Folders</h1>
<p>In order to have a website, you need to have it set our in a specific way, but make it easy to navigate. This is how you set up your website folders and files:</p>
<ol>
<li> Create a folder on your hard drive or a USB called "Website".</li>
<li>Open a blank Notepad++ document.</li>
<li>Save the blank document in your "Website" folder with the name "Index", and a file extension of ".html".</li>
<li>Open another blank Notepad++ document and call it "StyleSheet" with the file extension of ".css". Save it in your "Website: folder as well.</li>
<li>Inside your "Website" folder, create another folder called "Images".</li>
<li>If you wish to include music on your website, create another folder in your "Website" folder called "Audio".</li>
</ol>
<p>Your website folder should now look something like this:</p>
<img src="Images/webfolderdemo.jpg" width="80%" height="80%">
<p>Remember whenever you add pictures, put them in the "Images" folder, and music or other audio, put in the "Audio" folder."
<div class="needs">
<a href="index.html">
<button type="button" class="needs">1. Things you need</button>
</a>
</div>
<div class="extrainfo">
<a href="extrainfo.html">
<button type="button" class="extrainfo">3. Extra Information</button>
</a>
</div>
</div>
</div>
</div>
</body>
</html>
CSS
#body {
background: url(Images/bigimage.jpg);
background-color:#000000;
background-size: 100% 100%;
width: auto;
height: auto;
background-repeat: no-repeat;
background-attachment: fixed;
margin: 0px;
margin-top: 0px;
color: #FFFFFF;
}
.webheading {
size: 300px;
text-align: center;
color: #FFFF00;
font-family: "Arial Black", Gadget, sans-serif;
}
.needs {
display: inline-block;
font-weight: bold;
font-family: "Arial Black", Gadget, sans-serif;
border: 2px solid #FFFF00;
background-color: #00FF00;
border-radius: 10px;
height: auto;
width: 180px;
}
.needs:hover {
background-color: #4CAF50;
color: white;
}
.extrainfo {
float: right;
display: inline-block;
font-weight: bold;
font-family: "Arial Black", Gadget, sans-serif;
border: 2px solid #FFFF00;
background-color: #00FF00;
border-radius: 10px;
height: auto;
width: 180px;
}
.extrainfo:hover {
background-color: #4CAF50;
color: white;
}
.margin {
margin-left: 20px;
margin-right: 20px;
}
.shading {
border-radius: 15px;
width: auto;
height: auto;
padding: 10px 25px;
text-align: left;
background-color:rgba(0, 0, 0, 0.6)
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="setupstylesheet.css">
<title>Setting up Your Website Folders</title>
</head>
<body>
<div id="body">
<img src="Images/web-development-banner.jpg" width="100%" height="400">
<h1 class="webheading">Website Developement</h1>
<div class="margin">
<div class="shading">
<h1>2. Setting Up Your Website Folders</h1>
<p>In order to have a website, you need to have it set our in a specific way, but make it easy to navigate. This is how you set up your website folders and files:</p>
<ol>
<li> Create a folder on your hard drive or a USB called "Website".</li>
<li>Open a blank Notepad++ document.</li>
<li>Save the blank document in your "Website" folder with the name "Index", and a file extension of ".html".</li>
<li>Open another blank Notepad++ document and call it "StyleSheet" with the file extension of ".css". Save it in your "Website: folder as well.</li>
<li>Inside your "Website" folder, create another folder called "Images".</li>
<li>If you wish to include music on your website, create another folder in your "Website" folder called "Audio".</li>
</ol>
<p>Your website folder should now look something like this:</p>
<img src="Images/webfolderdemo.jpg" width="80%" height="80%">
<p>Remember whenever you add pictures, put them in the "Images" folder, and music or other audio, put in the "Audio" folder."
<div class="button-wrap">
<a href="index.html">
<button type="button" class="needs">1. Things you need</button>
</a>
</div>
<div class="button-wrap">
<a href="extrainfo.html">
<button type="button" class="extrainfo">3. Extra Information</button>
</a>
</div>
</div>
</div>
</div>
</body>
</html>
css -->
.button-wrap {
display: inline-block;
width: 171px;
}
remove float:right from .extrainfo
removed width for both buttons.
You can simplify your markup like that :
<div class="container">
<a href="index.html" class="button needs">
1. Things you need
</a>
<a href="extrainfo.html" class="button extrainfo">
3. Extra Information
</a>
</div>
And CSS could be something like that :
.container {
text-align: center;
}
.button_test {
display: inline-block;
font-weight: bold;
font-family: "Arial Black", Gadget, sans-serif;
border: 2px solid #FFFF00;
background-color: #00FF00;
border-radius: 10px;
height: auto;
width: 180px;
}
.button_test.extrainfo {
// CSS for .extrainfo
}`
It is because your buttons are 'floating'. you should not have the same class on the button and container as mentioned above in the comments.
Once you have your button/div class situation fixed, you can use clear: both; on the containers and/or display: block; or display: block-inline; and that should stop the buttons from overlapping.
As long as you change the "float" attribute in the class that binds onto the buttons, the buttons would not be overlapping anymore.
If i am not mistaken, you can keep your "float" if you add "padding " attribute to your buttons
OK. I fixed it.
I stupidly had the same class name for my divs and my buttons, so thats why it was doubling up. I also found a much easier solution for aligning my buttons on the same row as eachother. Rather than having a div around each button, I did this instead:
HTML:
<div>
<a href="index.html">
<button type="button" class="needs">1. Things you need</button>
</a>
<a href="extrainfo.html">
<button type="button" class="extrainfo">3. Extra Information</button>
</a>
</div>
As for the CSS, nothing needed to be changed:
.needs {
display: inline-block;
font-weight: bold;
font-family: "Arial Black", Gadget, sans-serif;
border: 2px solid #FFFF00;
background-color: #00FF00;
border-radius: 10px;
height: auto;
width: 180px;
}
.needs:hover {
background-color: #4CAF50;
color: white;
}
.extrainfo {
float: right;
display: inline-block;
font-weight: bold;
font-family: "Arial Black", Gadget, sans-serif;
border: 2px solid #FFFF00;
background-color: #00FF00;
border-radius: 10px;
height: auto;
width: 180px;
}
.extrainfo:hover {
background-color: #4CAF50;
color: white;
}
a {
text-decoration: none;
}
.social {
padding-left: 670px;
/*margin-left: 670px;*/
margin-top: -140px;
}
.blog_roll_links {
margin-left: 58px;
width: 210px;
height: 40px;
line-height: 40px;
}
.blog_roll_links:hover {
background-color: #C74451;
color: white !important;
text-shadow: 1px 1px 1px black;
}
.social_links {
padding-left: 8px;
margin-left: 40px;
width: 140px;
height: 30px;
line-height: 30px;
}
<div class="bolgnsocial">
<div class="blog">
<h3 class="featArt">blogroll</h3>
<div class="blog_roll_links">
HTML5 Doctor
</div>
<div class="blog_roll_links" style="margin-left:17em; margin-top: -40px;">
HTML5 Spec (working draft)
</div>
<div class="blog_roll_links">
Super Magazine
</div>
</div>
<div class="social">
<h3 class="featArt">social</h3>
<div class="social_links blog_roll_links">
facebook
</div>
<hr align="right" style="border-style: outset; border-color: white; margin-left: 45px; width: 140px;" />
<div class="social_links blog_roll_links">
twitter
</div>
</div>
</div>
I have this little snip of code and two questions:
The "facebook" and "twitter" have the same class of "blog_roll_links", however, the final result is different. It supposed to change the div color when hovered over the link, like the links in blog does. I just cannot figure it out why "blog" and "social" have the same class, but don't have the same effect.
I want to change the text color to white when hovered over, i have the code in my CSS, why it won't work?
Hi I highly recommend you to explore the browsers (chrome recommended) development tools.
if you inspect the elements you will see that in your current styling, that the anchor is nested inside your div AND that the anchor doesn't have the same width and height.
depending on which class you are adding :hover, css will react accordingly.
also the color of the font belongs to the anchor.
My suggestion is that you wrap the styling div inside the anchor, so that the whole div becomes a link ;)
Hope this helps you
I'm attempting to place a 'notification' style badge over an images. I am using Twitters Bootstrap as a base framework and creating a custom CSS class called notify-badge. But I cannot get anything to line up properly.
Through the magic of Photoshop, here is what I am trying to accomplish.
Here is my CSS code.
.notify-badge{
position: absolute;
background: rgba(0,0,255,1);
height:2rem;
top:1rem;
right:1.5rem;
width:2rem;
text-align: center;
line-height: 2rem;;
font-size: 1rem;
border-radius: 50%;
color:white;
border:1px solid blue;
}
I would like to be able to place any small about of text in the badge and it expand the red circle to fit.
Here is my HTML code.
<div class="col-sm-4">
<a href="#">
<span class="notify-badge">NEW</span>
<img src="myimage.png" alt="" width="64" height="64">
</a>
<p>Some text</p>
</div>
Bunch of different ways you can accomplish this. This should get you started:
.item {
position:relative;
padding-top:20px;
display:inline-block;
}
.notify-badge{
position: absolute;
right:-20px;
top:10px;
background:red;
text-align: center;
border-radius: 30px 30px 30px 30px;
color:white;
padding:5px 10px;
font-size:20px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="col-sm-4">
<div class="item">
<a href="#">
<span class="notify-badge">NEW</span>
<img src="https://picsum.photos/200" alt="" />
</a>
</div>
</div>
Addendum (from the Asker #user-44651)
(moved from the question)
Here is the result of applying this answer.
Adding margin-top:-20px; to .item fixed the alignment issue.
The idea here is to overlay an absolute container on top of a relative one. Here's a similar example:
<div class="image">
<img src="images/3754004820_91a5c238a0.jpg" alt="" />
<h2>A Movie in the Park:<br />Kung Fu Panda</h2>
</div>
The CSS:
.image {
position: relative;
width: 100%; /* for IE 6 */
}
h2 {
position: absolute;
top: 200px;
left: 0;
width: 100%;
}
This is going to put our text right up on top of the image nicely, but it doesn't accomplish the box we want to achieve behind the text. For that, we can't use the h2, because that is a block level element and we need an inline element without an specific width. So, wrap the h2 inside of a span.
<h2><span>A Movie in the Park:<br />Kung Fu Panda</span></h2>
Then use that span to style and text:
h2 span {
color: white;
font: bold 24px/45px Helvetica, Sans-Serif;
letter-spacing: -1px;
background: rgb(0, 0, 0); /* fallback color */
background: rgba(0, 0, 0, 0.7);
padding: 10px;
}
For ideas on how to ensure proper spacing or to use jQuery to cleanup the code a bit by allowing you to remove some of the tags from the code and jQuery them back in, check the source.
Here's a fiddle I made with the sample code:
https://jsfiddle.net/un2p8gow/
I changed the notify-badge span into a div. I saw no reason it had to be a span.
I changed the position to relative. Edit - you could actually keep the attribute position: absolute; provided you know what you're doing with it. Guy in the comments was right.
You had the attribute right: 1.5rem; and I simply changed it to left because it was being inset in the opposite direction of your example.
You can tweak it further but in a vacuum this is what you want.