CSS opacity layer trouble [duplicate] - html

This question already has answers here:
Making text background transparent but not text itself
(9 answers)
Closed 5 years ago.
I want the background to have an opacity of .8 but not affect the other elements on top. How can I do this?
HTML
<div id="background">
<div id="foreground">
<div class="row">
<div class="column">
<div class="card">
<img src="lee2.png" alt="Jane" style="width:200px; height:200px">
<div class="container">
<h2>Lee Hannigan</h2>
<p class="title">CEO & Founder</p>
<p>Some text that describes me lorem ipsum ipsum lorem.</p>
<p>lee#stokeddesigns.com</p>
<p><button class="button">Contact</button></p>
</div>
</div>
</div>
<div class="column">
<div class="card">
<img src="bosco2.png" alt="Mike" style="width:200px; height:200px;">
<div class="container">
<h2>Bosco</h2>
<p class="title">Lead Developer</p>
<p>Some text that describes me lorem ipsum ipsum lorem.</p>
<p>bosco#stokeddesigns.com</p>
<p><button class="button">Contact</button></p>
</div>
</div>
</div>
<div class="column">
<div class="card">
<img src="cat2.png" alt="John" style="width:200px;height:200px;">
<div class="container">
<h2>Caitriona Lyons</h2>
<p class="title">Designer</p>
<p>Some text that describes me lorem ipsum ipsum lorem.</p>
<p>cat#stokeddesigns.com</p>
<p><button class="button">Contact</button></p>
</div>
</div>
</div>
</div>
</div>
</div>
CSS
/* Three columns side by side */
.column {
float: left;
width: 25%;
margin-bottom: 16px;
margin-left:70px;
padding: 0 8px;
background-color: grey;
}
.card {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
}
.container {
padding: 0 16px;
}
/* Clear floats */
.container::after, .row::after {
content: "";
clear: both;
display: table;
}
.title {
color: #453A3A;
}
.button {
border: none;
outline: 0;
display: inline-block;
padding: 8px;
color: white;
background-color: #000;
text-align: center;
cursor: pointer;
width: 100%;
}
.button:hover {
background-color: #555;
}
#background{
background-color: #ED9300;
opacity:0.8;
}
#foreground{
text-align: center;
margin-top: 100px;
padding: 50px;
}
This is what the page looks like now

Use rgba coloring for the orange stripe instead of opacity. So like this:
background-color: rgba(215, 130, 44, 0.8);
The 0.8 is the opacity wich can be between 0 and 1
Hope this helps!

Instead of using the opacity, change the background-color to an RGBA instead of a hex. While opacity makes all child elements see through, using an RGBA does not.

Related

How do i add an horizontal line using html and css in bootstrap 4

I want to add a small horizontal line like the one on the page.
I tried using the <hr\> tag but i don't get the desired line, is there any other way to add this line.
The code below describes what i've done so far to construct the line but i have not been able to achieve it.
Please could someone help me create the line
Thanks
.second-bg-cover{
background-image: linear-gradient(rgba(0, 0, 0, 0.7),rgba(0, 0, 0, 0.5)) ,url(../img/state1.jpg);
width: 100%;
height: 320px;
background-repeat: no-repeat;
position: relative;
z-index: -1;
}
.second-cover-heading {
position: absolute;
z-index: 1;
padding: 60px 0;
color: var(--white);
}
.second-cover-photo-section h1{
font-family: 'Raleway',sans-serif;
font-weight: 400;
}
.second-cover-download{
background: transparent;
color: white;
padding: 8px 18px;
border-color: var(--white);
position: relative;
z-index: 2;
}
.second-cover-download{
margin-left:580px;
margin-top: 25px;
}
<div class="row">
<div class="col-md-12">
<div class="second-bg-cover"></div>
</div>
<div class="col-md-12 second-cover-heading">
<h1 class="text-center">STYLISH AXURE DESIGN</h1>
<hr style="width:80px;height:2px;text-align:left;margin-left:660px;border: 1.5px solid white; color: white;">
<p class="text-center mt-4">Use the selections you need, remove the lines you don't need.Create gorgeous prototypes faster than ever!
</p>
<div class="second-cover-download">
<button class="second-cover-download ms-5" type="button">Download</button>
</div>
</div>
</div>
You can use the ::after like this:
HTML:
<h1 class="text-center with_underline">STYLISH AXURE DESIGN</h1>
CSS:
.with_underline::after{
content: "";
height: 3px;
width: 120px;
background: red;
display: block;
margin: 0 auto;
margin-top: 10px;
}
Here's the fiddle: https://jsfiddle.net/43e6r07m/
You can use the hrtag to create a line, or create a class named "spacer" that will allow you to customize the line. For example :
.spacer{
width:100%;
border:2px solid rgba(0,0,0,0.2);
margin:0;
box-sizing: border-box;
}
.myContainer{
width:80%;
margin-left:auto;
margin-right:auto;
}
<div class="myContainer">
Lorem ipsum dolor sit amet...
<div class="spacer"></div>
</div>

Placing items horizontally on Page [duplicate]

This question already has answers here:
Text floating in block next to image
(6 answers)
Closed 2 years ago.
I am new to html + css and I can't seem to figure out how you place items horizontally despite reading a couple articles. What I am going for is having two lines of text on the right side of my image. Currently I have everything placed vertically.
Html:
#content {
max-width: 640px;
margin: 0 auto;
padding: 64px 24px;
}
.section {
padding-bottom: 48px;
margin-bottom: 48px;
border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.section:last-of-type {
border-bottom: 0;
padding-bottom: 0;
margin-bottom: 0;
}
.img {
width: 200px;
height: 200px;
border-radius: 40px;
margin-bottom: 12px;
}
```
<body>
<div id="content">
<div class="section">
<img src="Images/Logo.png" class="img">
<h1>Placeholder</h1>
<h2>Placeholder 2</h2>
</div>
<div class="section">
<h6>Projects</h6>
<ul>
<li>
<h3>Placeholder</h3>
<p> Placeholder </p>
</li>
<li>
<h3>Placeholder </h3>
<p> Placeholder </p>
</li>
</ul>
</div>
</div>
</body>
I am not sure if I am sharing everything I need too, Here's the GitHub repo with all the code if you need it.
You can use display: flex; property.
/* ↓ new styling ↓ */
.section-horizontal {
display: flex;
}
.description {
margin-left: 32px;
}
/* your styling */
#content {
max-width: 640px;
margin: 0 auto;
padding: 64px 24px;
}
.section {
padding-bottom: 48px;
margin-bottom: 48px;
border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.section:last-of-type {
border-bottom: 0;
padding-bottom: 0;
margin-bottom: 0;
}
.img {
width: 200px;
height: 200px;
border-radius: 40px;
margin-bottom: 12px;
}
<div id="content">
<div class="section section-horizontal"> <!-- class for flexbox -->
<img src="Images/Logo.png" class="img">
<div class="description"> <!-- add this block to align headings vertically -->
<h1>Placeholder</h1>
<h2>Placeholder 2</h2>
</div>
</div>
<div class="section">
<h6>Projects</h6>
<ul>
<li>
<h3>Placeholder</h3>
<p> Placeholder </p>
</li>
<li>
<h3>Placeholder </h3>
<p> Placeholder </p>
</li>
</ul>
</div>
</div>
try to get in touch with the flex property. It will make things alot more simple :)
html:
<body>
<div id="content">
<div class="section">
<img src="Images/Logo.png" class="img">
<div class="flex">
<h1>Placeholder</h1>
<h2>Placeholder 2</h2>
</div>
</div>
</div>
</body>
css:
.flex {
display: flex;
}
You can do with flexbox like this
#content {
max-width: 640px;
margin: auto;
padding: 64px 24px;
display:flex;
flex-wrap:wrap;
justify-content: space-evenly;
}
.section {
padding-bottom: 48px;
margin-bottom: 48px;
border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.section:last-of-type {
border-bottom: 0;
padding-bottom: 0;
margin-bottom: 0;
}
.img {
width: 200px;
height: 200px;
border-radius: 40px;
margin-bottom: 12px;
}
<body>
<div id="content">
<div class="section">
<img src="Images/Logo.png" class="img">
<h1>Placeholder</h1>
<h2>Placeholder 2</h2>
</div>
<div class="section">
<h6>Projects</h6>
<ul>
<li>
<h3>Placeholder</h3>
<p> Placeholder </p>
</li>
<li>
<h3>Placeholder </h3>
<p> Placeholder </p>
</li>
</ul>
</div>
</div>
</body>

Lining up elements (creating a 2x2 card grid)

I am working on a website (html), and am having some trouble making elements line up properly. Right now, my page looks like HERE, but I want it to look like HERE.
Essentially, I want to create a 2 by 2 grid.
I don't know which part of the code is not permitting me from having 2 elements on one line.
Thanks in advance for your help!
<title></title>
<style type="text/css">body {
color: #404040;
font-size: 14px;
line-height: 22px;
padding-top: 20px;
}
.card {
display: inline-block;
box-shadow: 0 1px 2px 0 rgba(0,0,0,.15);
margin: 5px;
position: relative;
margin-bottom: 50px;
transition: all .2s ease-in-out;
}
.card:hover {
/*box-shadow: 0 5px 22px 0 rgba(0,0,0,.25);*/
box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
margin-bottom: 54px;
}
.image {
height: 200px;
opacity: .7;
overflow: hidden;
transition: all .2s ease-in-out;
}
.image:hover,
.card:hover .image {
height: 200px;
opacity: 1;
}
.text {
background: #FFF;
padding: 20px;
min-height: 200px;
}
.text p {
margin-bottom: 0px;
}
.fab {
width: 60px;
height: 60px;
border-radius: 50%;
position: absolute;
margin-top: -50px;
right: 20px;
box-shadow: 0px 2px 6px rgba(0, 0, 0, .3);
color: #fff;
font-size: 48px;
line-height: 48px;
text-align: center;
background: #0066A2;
-webkit-transition: -webkit-transform .2s ease-in-out;
transition: transform .2s ease-in-out;
}
.fab:hover {
background: #910500;
cursor: pointer;
-ms-transform: rotate(90deg);
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
</style>
<div class="container">
<div class="row">
<div class="col-md-3 col-lg-3 col-xs-3 col-sm-3">
<div class="card">
<div class="image"><img src="/sites/default/files/BannerTest.jpg" width="100%" /></div>
<div class="text">
<div class="fab">+</div>
<h3>Our Community</h3>
<p>Sample text Sample text Sample text Sample text Sample text Sample text Sample text Sample</p>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-3 col-lg-3 col-xs-3 col-sm-3">
<div class="card">
<div class="image"><img src="/sites/default/files/BannerTest.jpg" width="100%" /></div>
<div class="text">
<div class="fab">+</div>
<h3>Our Community</h3>
<p>Sample text Sample text Sample text Sample text Sample text Sample text Sample text Sample</p>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-3 col-lg-3 col-xs-3 col-sm-3">
<div class="card">
<div class="image"><img src="/sites/default/files/BannerTest.jpg" width="100%" /></div>
<div class="text">
<div class="fab">+</div>
<h3>Our Community</h3>
<p>Sample text Sample text Sample text Sample text Sample text Sample text Sample text Sample</p>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-3 col-lg-3 col-xs-3 col-sm-3">
<div class="card">
<div class="image"><img src="/sites/default/files/BannerTest.jpg" width="100%" /></div>
<div class="text">
<div class="fab">+</div>
<h3>Our Community</h3>
<p>Sample text Sample text Sample text Sample text Sample text Sample text Sample text Sample</p>
</div>
</div>
</div>
</div>
</div>
Here is the correct code:
<title></title>
<style type="text/css">
body {
color: #404040;
font-size: 14px;
line-height: 22px;
padding-top: 20px;
}
.card {
display: inline-block;
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, .15);
margin: 5px;
position: relative;
margin-bottom: 50px;
transition: all .2s ease-in-out;
}
.card:hover {
/*box-shadow: 0 5px 22px 0 rgba(0,0,0,.25);*/
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23);
margin-bottom: 54px;
}
.image {
height: 200px;
opacity: .7;
overflow: hidden;
transition: all .2s ease-in-out;
}
.image:hover,
.card:hover .image {
height: 200px;
opacity: 1;
}
.text {
background: #FFF;
padding: 20px;
min-height: 200px;
}
.text p {
margin-bottom: 0px;
}
.fab {
width: 60px;
height: 60px;
border-radius: 50%;
position: absolute;
margin-top: -50px;
right: 20px;
box-shadow: 0px 2px 6px rgba(0, 0, 0, .3);
color: #fff;
font-size: 48px;
line-height: 48px;
text-align: center;
background: #0066A2;
-webkit-transition: -webkit-transform .2s ease-in-out;
transition: transform .2s ease-in-out;
}
.fab:hover {
background: #910500;
cursor: pointer;
-ms-transform: rotate(90deg);
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
.row {
display: flex;
}
</style>
<div class="container">
<div class="row">
<div class="col-md-3 col-lg-3 col-xs-3 col-sm-3">
<div class="card">
<div class="image"><img src="/sites/default/files/BannerTest.jpg" width="100%" /></div>
<div class="text">
<div class="fab">+</div>
<h3>Our Community</h3>
<p>Sample text Sample text Sample text Sample text Sample text Sample text Sample text Sample</p>
</div>
</div>
</div>
<div class="col-md-3 col-lg-3 col-xs-3 col-sm-3">
<div class="card">
<div class="image"><img src="/sites/default/files/BannerTest.jpg" width="100%" /></div>
<div class="text">
<div class="fab">+</div>
<h3>Our Community</h3>
<p>Sample text Sample text Sample text Sample text Sample text Sample text Sample text Sample</p>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-3 col-lg-3 col-xs-3 col-sm-3">
<div class="card">
<div class="image"><img src="/sites/default/files/BannerTest.jpg" width="100%" /></div>
<div class="text">
<div class="fab">+</div>
<h3>Our Community</h3>
<p>Sample text Sample text Sample text Sample text Sample text Sample text Sample text Sample</p>
</div>
</div>
</div>
<div class="col-md-3 col-lg-3 col-xs-3 col-sm-3">
<div class="card">
<div class="image"><img src="/sites/default/files/BannerTest.jpg" width="100%" /></div>
<div class="text">
<div class="fab">+</div>
<h3>Our Community</h3>
<p>Sample text Sample text Sample text Sample text Sample text Sample text Sample text Sample</p>
</div>
</div>
</div>
</div>
check this
wrap the elements in div then use display:flex
https://jsfiddle.net/rkv88/ug3qk1m5
To keep 2 or more divs inline we can use different css properties like:
display: inlie-block, float: left, useing table, display: table and display:table-cell, flex box and so on. Here is a simple example below
body * {
box-sizing: border-box; /* very usefull for responsive design */
}
.container {
width: 100%;
float: left; /* not necessary all the times, depends*/
}
.card {
width: 50%;
float: left;
padding: 10px;
}
.card:nth-child(:nth-child(2n+1) {
clear: left
}
As you can see in the example below, you can achieve your goal:
.wrapper {
display: flex;
flex-wrap: wrap;
}
.item {
height: 100px;
flex-basis: 50%;
}
.red {
background-color: red;
}
.blue {
background-color: blue;
}
.green {
background-color: green;
}
.cyan {
background-color: cyan;
}
<div class="wrapper">
<div class="item red">item 1</div>
<div class="item blue">item 2</div>
<div class="item green">item 3</div>
<div class="item cyan">item 4</div>
</div>
Hope this help you.
body {
color: #404040;
font-size: 14px;
line-height: 22px;
padding-top: 20px;
}
.card {
display: inline-block;
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, .15);
margin: 5px;
position: relative;
margin-bottom: 50px;
transition: all .2s ease-in-out;
}
.card:hover {
/*box-shadow: 0 5px 22px 0 rgba(0,0,0,.25);*/
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23);
margin-bottom: 54px;
}
.image {
height: 200px;
opacity: .7;
overflow: hidden;
transition: all .2s ease-in-out;
}
.image:hover,
.card:hover .image {
height: 200px;
opacity: 1;
}
.text {
background: #FFF;
padding: 20px;
min-height: 200px;
}
.text p {
margin-bottom: 0px;
}
.fab {
width: 60px;
height: 60px;
border-radius: 50%;
position: absolute;
margin-top: -50px;
right: 20px;
box-shadow: 0px 2px 6px rgba(0, 0, 0, .3);
color: #fff;
font-size: 48px;
line-height: 48px;
text-align: center;
background: #0066A2;
-webkit-transition: -webkit-transform .2s ease-in-out;
transition: transform .2s ease-in-out;
}
.fab:hover {
background: #910500;
cursor: pointer;
-ms-transform: rotate(90deg);
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/4.1.3/darkly/bootstrap.min.css">
<div class="container">
<div class="row">
<div class="col-md- col-lg-6 col-xs-6 col-sm-6">
<div class="card">
<div class="image"><img src="/sites/default/files/BannerTest.jpg" width="100%" /></div>
<div class="text">
<div class="fab">+</div>
<h3>Our Community</h3>
<p>Sample text Sample text Sample text Sample text Sample text Sample text Sample text Sample</p>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6 col-xs-6 col-sm-6">
<div class="card">
<div class="image"><img src="/sites/default/files/BannerTest.jpg" width="100%" /></div>
<div class="text">
<div class="fab">+</div>
<h3>Our Community</h3>
<p>Sample text Sample text Sample text Sample text Sample text Sample text Sample text Sample</p>
</div>
</div>
</div>
</div>
</div>

Can´t set border radius on one side and a regular border on the opposite side [duplicate]

This question already has answers here:
How to remove the space between inline/inline-block elements?
(41 answers)
Closed 4 years ago.
For some reason, my regular semi-transparent right border doesn´t work on the element which has border-radius on the left and bottom sides. How can I fix it?
See snippet and codepen:
body {
background: red;
}
.item {
margin-left: 10px;
}
.box {
border-right: 1px solid rgba(0, 0, 0, 0.3);
line-height: 10px;
margin-left: -5px;
display: inline-block;
width: 300px;
background: white;
}
.border {
border-right: 1px solid rgba(0, 0, 0, 0.3);
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
}
<div id="container">
<div class="box border">
<p class="item"> Origen</p>
<p class="item"> Buenos Aires</p>
</div>
<div class="box">
<p class="item"> Origen</p>
<p class="item"> Buenos Aires</p>
</div>
<div class="box">
<p class="item"> Origen</p>
<p class="item"> Buenos Aires</p>
</div>
</div>
Don't use negative margins to remove the space between inline elements. Set font-size to zero for the container and reset it for the box - see how the issue is solved by itself now:
body {
background: red;
}
.item {
margin-left: 10px;
}
#container {
font-size: 0; /* ADDED */
}
.box {
font-size: initial; /* ADDED */
border-right: 1px solid rgba(0, 0, 0, 0.3);
line-height: 10px;
/*margin-left: -5px;*/
display: inline-block;
width: 300px;
background: white;
}
.border {
border-right: 1px solid rgba(0, 0, 0, 0.3);
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
}
<div id="container">
<div class="box border">
<p class="item"> Origen</p>
<p class="item"> Buenos Aires</p>
</div>
<div class="box">
<p class="item"> Origen</p>
<p class="item"> Buenos Aires</p>
</div>
<div class="box">
<p class="item"> Origen</p>
<p class="item"> Buenos Aires</p>
</div>
</div>

CSS scalable chat bubble for text length?

I am having trouble creating a scalable div that increases/decreases in size based on the size of the text in the chat bubble. A good example is the chat bubble that messenger or facebook chat uses.
.left-chat-bubble{
background-color:gray;
padding:10px;
border-radius:40px;
max-width:300px;
}
<div class="left-chat-bubble-wrap">
<div class="left-chat-bubble">
<p>hello</p>
</div>
</div>
I can get it to the its maximum size but I cant get the bubble to wrap around the relative size of the text.
All you need is display to be set inline or inline-block. See this.
.left-chat-bubble{
display: inline-block;
background-color:gray;
padding:10px;
border-radius:40px;
max-width:300px;
}
<div class="left-chat-bubble-wrap">
<div class="left-chat-bubble">
<p>hello</p>
</div>
</div>
For a better chat-like layout you can go for this snippet:
Update
adding arrows will also useful for a better UI.
.msg-list {
width: 100%;
}
.messenger-container {
padding: 8px 15px 8px 13px;
margin: 0 0 25px 35px;
float: left;
max-width: 82%;
background: #f2f2f2;
border-radius: 10px;
min-width: 20%;
position: relative; box-sizing: border-box;
box-shadow: 7px 10px 6px -5px #BBC0C7;
}
.messenger-container p {
color: #3D3D3D;
font-size: 12px;
margin-bottom: 6px;
line-height: 18px;
word-wrap: break-word; margin: 0;
}
.sender .messenger-container {
float: right;
margin-right: 35px;
width: auto;
background: #D5DBFF;
margin-left: 0px;
padding: 8px 15px 8px 13px;
}
.clear {
clear:both;
width: 100%;
padding: 0px !important;
margin: 0px;
height:0px;
}
.messenger-container::before {
width: 0px;
height: 0px;
border-top: 8px solid transparent;
border-bottom: 8px solid transparent;
border-right:15px solid #f2f2f2;
content: "";
position: absolute;
top: 9px;
left: -15px;
}
.sender .messenger-container::before {
width: 0px;
height: 0px;
border-top: 8px solid transparent;
border-bottom: 8px solid transparent;
border-left: 15px solid #D5DBFF;
content: "";
position: absolute;
top: 9px;
left: 99%;border-right: none;
}
<div class="msg-list">
<div class="messenger-container">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry</p>
</div>
</div>
<div class="clear"></div>
<div class="msg-list sender">
<div class="messenger-container">
<p>Lorem Ipsum</p>
</div>
</div>
<div class="clear"></div>
<div class="msg-list">
<div class="messenger-container">
<p>Lorem Ipsum is simply dummy text</p>
</div>
</div>
<div class="clear"></div>
<div class="msg-list sender">
<div class="messenger-container">
<p>Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</p>
</div>
</div>
<div class="clear"></div>
Or you can use either display:inline-block or float:left and clear:both if you want them on top of each other.
.left-chat-bubble{
clear:both;
float:left;
background-color:gray;
padding:10px;
border-radius:40px;
max-width:300px;
}
<div class="left-chat-bubble-wrap">
<div class="left-chat-bubble">
<p>hello, this is a chat bubble</p>
</div>
<div class="left-chat-bubble">
<p>hello, this is a chat bubble with text that wraps onto multiple lines</p>
</div>
</div>
.left-chat-bubble{
background-color:gray;
padding:10px;
border-radius:40px;
display:table-cell;
}
<div class="left-chat-bubble-wrap">
<div class="left-chat-bubble">
<p>hello with more text</p>
</div>
</div>