Border opacity in css using rgba() not working - html

I am working on a simple login site template using html and css (no js yet) and for some reason when I use the border-color property in my css for the .main class and i use the rgba() function like this:
border-color: rgba(255, 255, 255, 0.5);
the rgb works but the alpha does not at all.
I tried doing this instead and i also removed the original line:
border: 60px solid rgba(255, 255, 255, 0.5);
I am using chrome version 108.
html {
height: 100%;
width: 100%;
font-family: Arial, Helvetica, sans-serif;
background-image: linear-gradient(red, lime);
}
.main {
margin: 60px;
border: 60px solid;
border-color: rgba(255, 255, 255, 0.5) !important;
/* Set border opacity */
border-radius: 30px;
background-color: rgba(255, 255, 255, 0.8);
}
.main input {
border-radius: 10px;
height: 30px;
background-color: lightgray;
}
.main input:focus {
background-color: white;
}
.main button {
height: 30px;
border-radius: 15px;
}
<center>
<div class="main">
<h1>Login</h1>
<p>Hello! To continue please log into our service:</p>
<h2>Email</h2>
<input type="email">
<h2>Password</h2>
<input type="password">
<br>
<br>
<button type="button" onclick='alert("logging in...")'>Login</button>
</div>
</center>

You need to add background-clip: padding-box; to limit the background to padding area and not have it under your border-color:
html {
height: 100%;
width: 100%;
font-family: Arial, Helvetica, sans-serif;
background-image: linear-gradient(red, lime);
}
.main {
margin: 60px;
border: 60px solid;
border-color: rgba(255, 255, 255, 0.5);
/* Set border opacity */
border-radius: 30px;
background-color: rgba(255, 255, 255, 0.8);
background-clip: padding-box
}
.main input {
border-radius: 10px;
height: 30px;
background-color: lightgray;
}
.main input:focus {
background-color: white;
}
.main button {
height: 30px;
border-radius: 15px;
}
<div class="main">
<h1>Login</h1>
<p>Hello! To continue please log into our service:</p>
<h2>Email</h2>
<input type="email">
<h2>Password</h2>
<input type="password">
<br>
<br>
<button type="button" onclick='alert("logging in...")'>Login</button>
</div>

I took a look and there's no issue.
You created two styles very similar and with 50% or more of opacity:
border-color: rgba(255, 255, 255, 0.5)
background-color: rgba(255, 255, 255, 0.8)
I suggest you to create a good contrast between the .main background and border.
In front-end, you will need to learn about design too. So, one of the videos I suggest you to learn how to manage colors is: https://youtu.be/Qj1FK8n7WgY?list=PLAiIx7LPQuH3FN2B2oBNiWhPCBC2NdqDe
I believe that a better contrast between the background and border, and an opacity below 50% will solve your problem.

Related

Vertical Linear Gradient

I am trying to get a vertical effect for a sidebar on a page. I have tried the deg option but it still shows a horizontal line
.sidebar {
position: relative;
display: inline-block;
padding: 15px 25px;
background-image: linear-gradient(90deg, #1559EC, #1559EC);
color: #fff;
font-size: 36px;
font-family: Arial;
border-radius: 3px;
box-shadow: 0px 1px 4px -2px #333;
text-shadow: 0px -1px #333;
}
.sidebar:after {
content: '';
position: absolute;
top: 2px;
left: 2px;
width: calc(100% - 4px);
height: 50%;
background: linear-gradient(rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.2));
}
<div class="sidebar">
The quick brown fox
</div>
The issue is not the gradient but the pseudo element. The gradient is using the same color so the angle is useless. What you need is to invert height/width values on the pseudo element and adjust the direction of its gradient. You can also replace the gradient of the main element by simple color:
.sidebar {
position: relative;
display: inline-block;
padding: 15px 25px;
background:#1559EC;
color: #fff;
font-size: 36px;
font-family: Arial;
border-radius: 3px;
box-shadow: 0px 1px 4px -2px #333;
text-shadow: 0px -1px #333;
}
.sidebar:after {
content: '';
position: absolute;
top: 2px;
left: 2px;
width: 50%;
height: calc(100% - 4px);
background: linear-gradient(to right,rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.2));
}
<div class="sidebar">
The quick brown fox
</div>
And you can simplify it like below using multiple background on the main element:
.sidebar {
position: relative;
display: inline-block;
padding: 15px 25px;
background:
linear-gradient(to right,rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.2)) 2px 2px/50% calc(100% - 4px)no-repeat,
#1559EC;
color: #fff;
font-size: 36px;
font-family: Arial;
border-radius: 3px;
box-shadow: 0px 1px 4px -2px #333;
text-shadow: 0px -1px #333;
}
<div class="sidebar">
The quick brown fox
</div>
The gradient you're trying to change has both colors the same so you won't see the difference. The easiest way to make what you want IS using a generator since the code for each render engine is a bit different.
The easiest keyword solution is to use "to direction" instead of a degree. See below. The first box is top to bottom and the second is left to right.
Your example has a pseudo-class (:after) adding a second gradient to create the hard line. You could achieve a similar effect by adding more stops to the gradient.
.box{
width: 100px;
height: 100px;
margin-bottom: 20px
}
.gradient1 {
background: linear-gradient(to bottom, #8fc400, #29b8e5);
}
.gradient2 {
background: linear-gradient(to right, #8fc400, #29b8e5);
}
.gradient3 {
background: linear-gradient(to bottom, rgba(191,210,85,1) 0%,rgba(142,185,42,1) 50%,rgba(114,170,0,1) 51%,rgba(158,203,45,1) 100%);
}
<div class="box gradient1">
</div>
<div class="box gradient2">
</div>
<div class="box gradient3">
</div>

CSS borders appearing and disappearing in MS Edge

My website code has an annoying problem. Whenever I view the page with Microsoft Edge and hover over a link, one of the borders turns and stays white until you hover over another link, which switches another border.
body {
font-family: Sans-Serif;
background-color: blue;
}
.Overhead {
background-color: red;
background-image: url('cats.jpg');
}
.Title {
margin: 5px;
}
.Active {
background-color: rgba(255, 255, 255, 1);
}
.Menu {
overflow: hidden;
}
.Menu a {
transition: .5s ease;
display: block;
text-align: center;
text-decoration: none;
color: grey;
padding: 5px;
float: left;
width-max: 50px;
background-color: rgba(255, 255, 255, 0.5);
}
.Menu a:visited {
color: grey;
}
.Menu a:hover {
background-color: rgba(255, 255, 255, 1);
}
<div class="Overhead">
<h1 class="Title">Title</h1>
<div class="Menu">
<a class="Active" style="background-color: rgba(255,255,255,1);"><b>Home</b></a>
<a><b>About</b></a>
<a><b>Service</b></a>
<a><b>Contact</b></a>
</div>
</div>
I'm looking for a way to change the CSS so the borders stop appearing. I tried to completely get rid of the border, but that didn't work. Is there any way to fix this?
if you don't want a border, just do this
border: 0px solid black;
this will make it so there isn't a border, if you ever see one.
In your code up there, there isn't a border, so use this if you see your border.
Note: it could just be border: 0px;, but I haven't tried it.
$('.a').mouseenter(function() {
$(this).css("border", "0px")
$(this).css("background-color", "rgba(255, 255, 255, 1)");
$(this).css("transition", "0.3s");
});
$('.a').mouseleave(function() {
$(this).css("border", "0px")
$(this).css("background-color", "rgba(255, 255, 255, 0.5)");
$(this).css("transition", "0.3s");
});
body {
font-family: Sans-Serif;
background-color: blue;
}
.Overhead {
background-color: red;
background-image: url('cats.jpg');
}
.Title {
margin: 5px;
}
.Active {
background-color: rgba(255, 255, 255, 1);
}
.Menu {
overflow: hidden;
}
.Menu a {
transition: .5s ease;
display: block;
text-align: center;
text-decoration: none;
color: grey;
padding: 5px;
float: left;
width-max: 50px;
background-color: rgba(255, 255, 255, 0.5);
}
.Menu a:visited {
color: grey;
}
.head {
border: 0px solid black;
}
#service {
margin-left: 0.4px;
}
#contact {
margin-left: 0.35px;
}
}
#container {
background-color: rgba(255, 255, 255, 0.5);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="Overhead">
<h1 class="Title">Title</h1>
<div class="Menu">
<div id="container">
<a class="Active" style="background-color: rgba(255,255,255,1);"><b>Home</b></a>
<a id="about" class="a"><b class="head">About</b></a>
<a id="service" class="a"><b class="head">Service</b></a>
<a id="contact" class="a"><b class="head">Contact</b></a>
</div>
</div>
</div>
I could replicate your problem. it is not a border, but actually two semi-transparent white backgrounds overlap in Ms Edge and creates a bolder white line. you can add margins between items in the menu, or a better solution could be to apply background-color: rgba(255, 255, 255, 0.5); to .Menu instead (set transparent background for menu items and keep the transition to white background on hover).
If you're using Microsoft Edge, this is because it's an Edge browser glitch. You will need to edit this so that it renders in MS Edge or just bear with it right now. Try placing space between the navbar items

Can't seem to make an A tag fill parent TD tag

I am trying to make an A tag fill the parent TD element. However, no matter what I try it doesn't seem to work.
I have viewed many various other Stack Overflow pages and they all state to do
child-element{
display: block;
width: 100%;
}
But this has not seemed to work in my case.
html {
font-family: "Times New Roman", Times, serif;
color: white;
}
#wrapper {
background-color: black;
background: #50a3a2;
background: -webkit-linear-gradient(top left, #50a3a2 0%, #53e3a6 100%);
background: linear-gradient(to bottom right, #50a3a2 0%, #53e3a6 100%);
}
a {
color: white;
text-decoration: none;
background-color: none;
cursor: pointer;
}
#wrapper,
#header,
#main {
padding: 10px 15px;
margin: 0 auto 10px auto;
text-align: center;
border: 1px solid rgba(255, 255, 255, 0.4);
background-color: rgba(255, 255, 255, 0.2);
}
#header {
min-width: 40vw;
max-width: 50vw;
}
#main {
min-height: 65vh;
}
.nav-link {
float: left;
padding: 10px 15px;
margin: 0 5px 0 5px;
border: 1px solid rgba(255, 255, 255, 0.4);
background-color: rgba(255, 255, 255, 0.2);
}
.nav-link:hover {
background-color: rgba(255, 255, 255, 0.4);
}
.nav-link a {
display: block;
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, 0.3);
}
<body>
<div id="wrapper">
<div id="header">
<table align="center">
<td class="nav-link">Main</td>
<td class="nav-link">Test</td>
<td class="nav-link">FAQ</td>
</table>
</div>
<div id="main">
<h1 style="line-height: 0%">Header</h1>
<p style="line-height: 0%; font-size: 1vw">_________________________________________________________________________________________________________</p>
<br>
<br>
</div>
</div>
</body>
If you would like to see this displayed you can view here: https://jsfiddle.net/wverhe/8gcypffm/
Remove the padding from .nav-link and add it to the .nav-link a. You can also remove the width and height from links since they will get resized from the padding.
html {
font-family: "Times New Roman", Times, serif;
color: white;
}
#wrapper {
background-color: black;
background: #50a3a2;
background: -webkit-linear-gradient(top left, #50a3a2 0%, #53e3a6 100%);
background: linear-gradient(to bottom right, #50a3a2 0%, #53e3a6 100%);
}
a {
color: white;
text-decoration: none;
background-color: none;
cursor: pointer;
}
#wrapper,
#header,
#main {
padding: 10px 15px;
margin: 0 auto 10px auto;
text-align: center;
border: 1px solid rgba(255, 255, 255, 0.4);
background-color: rgba(255, 255, 255, 0.2);
}
#header {
min-width: 40vw;
max-width: 50vw;
}
#main {
min-height: 65vh;
}
.nav-link {
float: left;
margin: 0 5px 0 5px;
border: 1px solid rgba(255, 255, 255, 0.4);
background-color: rgba(255, 255, 255, 0.2);
}
.nav-link:hover {
background-color: rgba(255, 255, 255, 0.4);
}
.nav-link a {
display: block;
padding: 10px 15px;
/* width: 100%; */
/* height: 100%; */
background-color: rgba(255, 255, 255, 0.3);
}
<body>
<div id="wrapper">
<div id="header">
<table align="center">
<td class="nav-link">Main</td>
<td class="nav-link">Test</td>
<td class="nav-link">FAQ</td>
</table>
</div>
<div id="main">
<h1 style="line-height: 0%">Header</h1>
<p style="line-height: 0%; font-size: 1vw">_________________________________________________________________________________________________________</p>
<br>
<br>
</div>
</div>
</body>
https://jsfiddle.net/8gcypffm/4/

CSS: border-radius // insert a background; white corners

So I'm totally new to HTML/CSS. I'm designing a fun project now to learn web development.
I created a search bar and wanted to add the famous round corners with border-radius. So far it works good. The problem is that the white background shines through the edges now, since the search bar is located in the menu bar.
I will post a screenshot and the code below. I'm not 100% familiar with the CSS box-model. I guess there lies the problem. Maybe I can fill the void with my menu background image? Hope someone can guide me where to fix this problem.
Screenshot:
https://picload.org/view/prwpirg/bildschirmfoto2015-09-20um16.3.png.html
HTML Code:
<!DOCTYPE html>
<html>
<head>
<title>facefuck</title>
<link rel="stylesheet" href="./css/style.css" type="text/css"/>
<link rel="icon" href="favicon.ico" type="image/x-icon" />
</head>
<body>
<div class="headerMenu">
<div id="wrapper">
<div class="logo">
<img src="./img/face_logo.jpg" />
</div>
<div class="search_box">
<form action="search.php" method="GET" id="search">
<input type="text" name="q" size="60" placeholder="Put your dick here" />
</form>
</div>
<div id="menu">
<a href="#" />Home</a>
<a href="#" />About</a>
<a href="#" />Sign Up</a>
<a href="#" />Sign In</a>
</div>
</div>
</div>
</body>
</html>
CSS Code:
* {
margin: 0px;
padding: 0px;
font-family: Arial, Helvetica, Sans-serif;
font-size: 12px;
background-color: #EAEDF5;
}
.headerMenu {
background-image: url("../img/menu_bg.png");
height: 60px;
border-bottom: 0px;
padding-left: auto;
padding-right: auto;
width: 100%;
}
#wrapper {
background-image: url("../img/menu_bg.png");
margin-left: auto;
margin-right: auto;
width: 1000px;
padding-top: 0px;
padding-bottom: 0px;
}
.logo {
background-image: url("../img/menu_bg.png");
width: 125px;
}
.logo img {
width: 150px;
height: 100%;
}
.search_box {
position: absolute;
top: 17px;
margin-left: 150px;
}
#search input[type="text"] {
background: url(../img/search_white.png) no-repeat 10px 6px #D8D8D8;
outline: none;
border: 0 none;
border-radius: 100px;
font: bold 12px Arial, Helvetica, Sans-serif;
width:300px;
padding: 5px 15px 5px 35px;
text-shadow: 0 2px 2px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
-moz-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
-webkit-transition: all 0.7s ease 0s;
-moz-transition: all 0.7s ease 0s;
-o-transition: all 0.7s ease 0s;
transition: all 0.7s ease 0s;
}
#search input[type="text"]:focus {
background: url(../img/search_black.png) no-repeat 10px 6pc #fcfcfc;
color: #6a6f75;
width: 300px;
-webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(0, 0, 0, 0.9) inset;
-moz-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(0, 0, 0, 0.9) inset;
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(0, 0, 0, 0.9) inset;
text-shadow: 0 2px 3px rgba(0, 0, 0, 0.1);
}
...
It is caused by
* {
background-color: #EAEDF5;
}
This will make your .search_box and form have that background color too. You can override it by using:
.search_box, form {
background-color: transparent;
}
I'd recommend removing the first rule, though, and only apply the #EAEDF5 background color to the body instead of all elements.
To visualize this with a concrete example:
* {
background-color: gray;
}
#a {
padding: 20px;
background-color: pink;
}
#c {
padding: 10px;
background-color: white;
border-radius: 20px;
}
<div id="a">
<div id="b">
<div id="c">
Hello world!
</div>
</div>
</div>
In the above example, the * selector will target all elements (all divs and the body), thus setting the background color of every div to gray. The two divs with ids a and c will override this background color, while b does not and get the background color it should use from the * selector, so it'll have a gray background color instead of the initial value of transparent, which would've let the pink shine through.
To fix the issue, either forcing the #b div to have a transparent background works or by changing the *-selector to body, which will then only color the background color of the page instead of every single element (unless overridden).
See my recommended fix in action here:
body {
background-color: gray;
}
#a {
padding: 20px;
background-color: pink;
}
#c {
padding: 10px;
background-color: white;
border-radius: 20px;
}
<div id="a">
<div id="b">
<div id="c">
Hello world!
</div>
</div>
</div>

Pure CSS Buttons

Could anyone show me some tutorials that make a button in css and doesn't require images? I googled it but everything involved images...
Thanks!
Um, define "button"? If you just want a basic button, you don't even need CSS, just use an HTML input or button tag...
<input type="button" value="Press me!" />
or
<button>Press me!</button>
If I understand you correctly, you want to make an arbitrary element look like a button?
Well ... just write CSS accordingly! Here's a kickoff example which makes a link look like a button:
<!DOCTYPE html>
<html lang="en">
<head>
<title>SO question 3489881</title>
<style>
a.button {
display: inline-block;
padding: 0 2px;
background: lightgray;
border: 2px outset lightgray;
cursor: default;
}
a.button:active {
border-style: inset;
}
</style>
</head>
<body>
<p><a class="button">link</a>
</body>
</html>
This one is kind of dull but gets the trick done!
h1 {
font-family: Arial;
}
a {
display: inline-block;
padding: 2 5px;
background: lightgray;
border: 5px outset lightgray;
cursor: default;
text-decoration:none;
color: black;
}
a:hover {
background: gray;
}
CSS:
.button{
background-color: #000;
color: #FF6600;
font: bolder 1.0em Tahoma;
border: 1px solid Yellow;
padding: 2px;
}
.button:hover{
border: 1px solid Red;
}
HTML:
<input type="button" class="button" value="Button"/>
<input type="button" class="button" value="Another"/>
Try it: http://jsfiddle.net/eD9sf/
There are some awesome examples here - Pure CSS Buttons - of buttons that don't need any images but are legit. I think that you could add some gradients to some of them, but otherwise they looks exactly like the ones on Facebook, Twitter, Wordpress, etc. If you don't know much CSS, I'd suggest that you just copy one of those examples.
This is a very simple design, but looks pretty good
body {
font-family: Helvetica, sans-serif;
font-size: .8rem;
}
.button {
text-align: center;
background-color: #888;
border-top: 0px solid #fff; /*define the color of the upper border */
border-bottom: 3px solid #666;
border-radius: 2px;
}
.button:hover {
box-shadow: inset 0 0 100px 100px rgba(255, 255, 255, 0.1); /* light overlay */
}
.button:active {
border-top-width: 2px; /* add this so it gets 'pushed down' */
border-bottom-width: 1px;
}
.button a {
color: #fff;
display: block;
text-decoration: none;
padding: .2rem;
}
/* Second button */
.button-link {
text-align: center;
color: #fff;
display: block;
text-decoration: none;
padding: .2rem;
background-color: #888;
border-top: 0px solid #fff; /*define the color of the upper border */
border-bottom: 3px solid #666;
border-radius: 2px;
}
.button-link:hover {
box-shadow: inset 0 0 100px 100px rgba(255, 255, 255, 0.1); /* light overlay */
}
.button-link:active {
border-top-width: 2px; /* add this so it gets 'pushed down' */
border-bottom-width: 1px;
}
<div class="button">Click me</div><br/>
<a class="button-link" href="#">Click me, link only</a>
This one looks lovely, acording to me :)
.button {
color: rgba(255, 255, 255, 1);
background-color: rgba(61, 51, 119, 1);
font-weight: 500;
padding: 9px;
box-shadow: 0px 5px 0px rgba(31, 36, 78, 1), 0px 9px 12px rgba(0, 0, 0, .7);
width: 160px;
text-align: center;
transition: all .3s ease;
font-size: 15px;
border: none;
border-radius: 5px;
outline: none;
margin: auto;
font-family: "Century Gothic";
transform: scale(0.9);
}
.button:active {
box-shadow: 0px 2px 0px rgba(31, 36, 78, 1), 0px 2px 4px rgba(0, 0, 0, .9);
top: 6px;
transform: scale(0.9) translateY(3px);
}
<input class = 'button' type = 'button' value = 'Click' />