I am trying to make text appear (with some styling) upon hover. I tried to use display:none; and then with hover display:block; but this hasnt worked.
<div class="container-fluid sub-head">
<div class="row">
<div class="col-md left">
<div class="title">Title</div>
<div class="overlay">
<div class="overlay-content">
<p>
some text
</p>
<p>more text.</p>
</div>
</div>
</div>
<div class="col-md right">
<div class="title">other title</div>
</div>
</div>
</div>
.row {
background: #f8f9fa;
margin-top: 20px;
}
.col-md {
border: solid 1px #6c757d;
height: 100px;
}
.overlay {
height: 100%;
display:none;
}
.overlay:hover {
display: block;
}
fiddle is here;
http://jsfiddle.net/2dyvLf5o/14/
If you want to see content of p element (more text), you should define a class name for this element and set hover style to it`s parent div, I also put title inside overlay div
enter code here
.row {
background: #f8f9fa;
margin-top: 20px;
}
.col-md {
border: solid 1px #6c757d;
}
.overlay{
height:150px
}
.hidden-content {
display: none;
}
.overlay:hover .hidden-content{
display: block;
}
<div class="container-fluid sub-head">
<div class="row">
<div class="col-md left">
<div class="overlay">
<h1 class="title">Title</h1>
<div class="overlay-content">
<p>
some text
</p>
<p class="hidden-content">more text.</p>
</div>
</div>
</div>
<div class="col-md right">
<h1 class="title">other title</h1>
</div>
</div>
</div>
Use :hover on a parent element, like this:
.row {
background: #f8f9fa;
margin-top: 20px;
}
.col-md {
border: solid 1px #6c757d;
height: 100px;
}
.overlay {
height: 100%;
display: none;
}
.row:hover .overlay {
display: block;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<div class="container-fluid sub-head">
<div class="row">
<div class="col-md left">
<div class="title">Title</div>
<div class="overlay">
<div class="overlay-content">
<p>
some text
</p>
<p>more text.</p>
</div>
</div>
</div>
<div class="col-md right">
<div class="title">Other title</div>
</div>
</div>
</div>
Related
Basically, I have some text with a border as such.
However, I want to achieve something like this, where the top bit has an orange colour and there are icons, how do I do so?
Code:
<div>
<p style="font-family: 'Space Grotesk'; margin-top: 100px; margin-left: 230px; border: 2px solid black; width: 250px; padding-left: 20px; height: 280px; padding-top: 40px; border-radius: 10px;">Awesome product! Works well. Easy to wear, great color scheme, does not tear easily and came home in under two days. Worth every rupee, it really helped me save money from buying the one-time use patches and rubber patches and has been a great experience with the patch.</p>
<hr style="height: 2px; background-color: black; margin-top: -314px; width: 270px; margin-left: 232px; border: none; position: relative;">
<h3 style="font-family: 'Space Grotesk'; margin-top: 230px; margin-left: 350px;">Rishan Reddy</h3>
<h3 style="font-family: 'Space Grotesk'; margin-left: 420px; margin-top: -12px;">Indus</h3>
</div>
Also, I want to make three of these divs side by side. How do I accomplish that?
Use fontawesome for your ellipsis. The header and content can be done as two divs in a container as below. It should be self-explanatory however if not, drop me a comment and I'll elaborate
.container {
border: 2px solid black;
border-radius: 1rem;
width: fit-content;
max-width: 30ch;
overflow: hidden;
min-height:10rem;
}
p {
margin: 0;
}
.header {
font-size: 1.5em;
background-color: #FFBF23;
line-height: 1.5rem;
padding-inline: 1rem;
border-bottom: 2px solid black;
}
.content {
padding: 1.5rem 1rem;
}
.signature-container {
margin-top:0.5rem;
display: flex;
justify-content: flex-end;
}
.review-container {
display:grid;
gap:1rem;
grid-template-columns:repeat(3, fit-content(30ch));
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css" integrity="sha512-xh6O/CkQoPOWDdYTDqeRdPCVd1SpvCA9XXcUnZS2FmJNp1coAFzvtCN9BmamE+4aHK8yyUHUSCcJHgXloTyT2A==" crossorigin="anonymous" referrerpolicy="no-referrer"
/>
<div class='review-container'>
<div class='container'>
<div class='header'>
<i class="fa-solid fa-ellipsis"></i>
</div>
<div class='content'>
<p>This is Review 1</p>
<div class='signature-container'>
<div>
<p>Adam Silver</p>
<p>Ashburn</p>
<p>Virginia</p>
</div>
</div>
</div>
</div>
<div class='container'>
<div class='header'>
<i class="fa-solid fa-ellipsis"></i>
</div>
<div class='content'>
<p>This is Review 2</p>
<div class='signature-container'>
<div>
<p>Adam Silver</p>
<p>Ashburn</p>
<p>Virginia</p>
</div>
</div>
</div>
</div>
<div class='container'>
<div class='header'>
<i class="fa-solid fa-ellipsis"></i>
</div>
<div class='content'>
<p>This is Review 3</p>
<div class='signature-container'>
<div>
<p>Adam Silver</p>
<p>Ashburn</p>
<p>Virginia</p>
</div>
</div>
</div>
</div>
<div class='container'>
<div class='header'>
<i class="fa-solid fa-ellipsis"></i>
</div>
<div class='content'>
<p>This is Review 4</p>
<div class='signature-container'>
<div>
<p>Adam Silver</p>
<p>Ashburn</p>
<p>Virginia</p>
</div>
</div>
</div>
</div>
</div>
I'm working on a project where I'm using bootstrap flex-box. I have attached the link to the layout that I'm using. I need to change the column on the right side to downwards when using on different devices except on pc.
This is what I want to get
<div class="d-flex flex-row">
<div class="flex-column"></div>
<div class="flex-column"></div>
</div>
I think you mean this... the right-most column gets to the bottom on a size smaller than lg... you can change the behavior on smaller screens through relevant classes;
UPDATE: added code for the same effect with flex
check the code snippet below:
.leftSection div {
border: 2px solid red;
height: 150px;
background: #000;
margin-top: 5px;
}
.leftSection div:nth-child(1) {
height: 300px
}
.rightSection div {
border: 2px dotted pink;
height: 100px;
background: gray;
margin-top: 5px;
}
.flexDirection>div {
min-height: 100px;
min-width: 100px;
display: flex;
flex-direction: column;
}
.flexDirection {
display: flex;
flex-direction: row;
}
#media screen and (max-width:992px) {
.flexDirection {
flex-direction: column;
}
}
.flexDirection>div:nth-of-type(1) {
flex-grow: 2;
}
.flexDirection>div:nth-of-type(2) {
flex-grow: 1;
}
.flexDirection div {
margin-top: 5px;
}
.leftSectionFlex>div:nth-child(1) {
border: 2px solid red;
height: 300px;
width: 100%;
background: #000;
margin-top: 5px;
}
.leftSectionFlexBottom {
display: flex;
flex-direction: row!important;
}
.leftSectionFlexBottom>div {
border: 1px solid red;
height: 150px;
width: 100%;
background: #000;
}
.rightSectionFlex>div {
border: 2px dotted pink;
height: 100px;
width: 100%;
background: gray;
margin-top: 5px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<h2>Flex</h2>
<div class="d-flex flexDirection">
<div class=" flex-column">
<div class="leftSectionFlex flex-row">
<div class=""></div>
<div class="leftSectionFlexBottom">
<div class=""></div>
<div class=""></div>
<div class=""></div>
</div>
</div>
</div>
<div class=" rightSectionFlex flex-column">
<div class=""></div>
<div class=""></div>
<div class=""></div>
</div>
</div>
<hr/>
<!--
-->
<h2> Bootstrap grid</h2>
<div class="container-fluid">
<div class="row">
<div class="col-lg-8">
<div class="row leftSection">
<div class="col-md-12"></div>
<div class="col-md-4"></div>
<div class="col-md-4"></div>
<div class="col-md-4"></div>
</div>
</div>
<div class="col-lg-4">
<div class="row rightSection">
<div class="col-lg-12 col-md-12"></div>
<div class="col-lg-12 col-md-12"></div>
<div class="col-lg-12 col-md-12"></div>
</div>
</div>
</div>
</div>
if you are using bootstrap-4 you can follow this structure. bootstrap 4 grid structure is all depends on flex and you can use the following structure for the devices except PC for the structure you want.
.box-content{
height: 300px;
background-color: #000;
border: 2px solid red;
margin-bottom: 20px;
}
.big-box{
height: 600px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<div class="container-fluid">
<div class="row">
<div class="col-xl-9">
<div class="box-content big-box"></div>
<div class="row">
<div class="col-4">
<div class="box-content"></div>
</div>
<div class="col-4">
<div class="box-content"></div>
</div>
<div class="col-4">
<div class="box-content"></div>
</div>
</div>
</div>
<div class="col-xl-3">
<div class="row">
<div class="col-12">
<div class="box-content"></div>
</div>
<div class="col-12">
<div class="box-content"></div>
</div>
<div class="col-12">
<div class="box-content"></div>
</div>
</div>
</div>
</div>
</div>
You can create it purely using flex-box in following way. But I would recommend you to go for css grid for 2 dimensional layout.
Code:
.container {
display: flex;
}
.container div {
border: 1px solid #e1e1e1;
margin: 4px;
text-align: center;
}
.main {
flex: 4;
}
.sidebar {
flex: 1;
}
.abc {
display: flex;
}
.abc div {
flex: 1;
}
#media screen and (max-width: 980px) {
.container {
flex-direction: column;
}
.sidebar {
display: flex;
}
.sidebar div {
flex: 1;
}
}
<div class="container">
<div class="main">
<div>1</div>
<div class="abc">
<div>2</div>
<div>3</div>
<div>4</div>
</div>
</div>
<div class="sidebar">
<div>5</div>
<div>6</div>
<div>7</div>
</div>
</div>
CSS Grid example:
https://gridbyexample.com
http://cssgrid.io/
Same as You want.
.demo{
background: #000;
height: 200px;
border: 2px solid red;
margin: 15px 0;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<body>
<div class="container-fluid">
<div class="row">
<div class="col-lg-8 col-md-12">
<div class="row">
<div class="col-md-12">
<div class="demo"></div>
</div>
<div class="col-md-4 col-sm-4">
<div class="demo"></div>
</div>
<div class="col-md-4 col-sm-4">
<div class="demo"></div>
</div>
<div class="col-md-4 col-sm-4">
<div class="demo"></div>
</div>
</div>
</div>
<div class="col-lg-4 col-md-12">
<div class="row">
<div class="col-md-12">
<div class="demo"></div>
</div>
<div class="col-md-12">
<div class="demo"></div>
</div>
<div class="col-md-12">
<div class="demo"></div>
</div>
</div>
</div>
</div>
</div>
</body>
I have been writing some code for a website, and I'm not able to vertically center text. I have read multiple answers on StackOverflow and other sites about how to vertically center html (mainly using the display:table and display:table-cell methods and the top:50%, transformY method), however, I am not able to implement either of these methods successfully. I have attached my code here, hoping that someone will be able to spot an error of my mine which is causing the code to not work. (In this code, I have used the top:50%, transformY method of vertically centering text). Any help would be greatly appreciated.
HTML:
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="stylesheet.css">
<title>Game Timer and Scorekeeper</title>
</head>
<body>
<div class="container-fluid">
<div class="row" id="heading">
<div class="col-xs-12">
<div class="positioner">
<h1>Game Timer and Scorekeeper</h1>
</div>
</div>
</div>
<div class="row" id="top-labels">
<div class="col-xs-3 labels teamlabel" id="a-label">
<div class="positioner">
<h2>Team A</h2>
</div>
</div>
<div class="col-xs-6 labels" id="gameclock-label">
<div class="positioner">
<h2>Game Clock</h2>
</div>
</div>
<div class="col-xs-3 labels teamlabel" id="b-label">
<div class="positioner">
<h2>Team B</h2>
</div>
</div>
</div>
<div class="row" id="thirdrow">
<div class="col-xs-3 pointsclock teampoints" id="pointsA">
<div class="positioner">
<h1>POINTS A</h1>
</div>
</div>
<div class="col-xs-6 pointsclock" id="gameclock">
<div class="positioner">
<h1>GAME CLOCK</h1>
</div>
</div>
<div class="col-xs-3 pointsclock teampoints" id="pointsB">
<div class="positioner">
<h1>POINTS B</h1>
</div>
</div>
</div>
<div class="row" id="fourthrow">
<div class="col-xs-3 ptcontclock ptcontrol" id="ptcontrolA">
<div class="positioner">
<h2>CONTROL A</h2>
</div>
</div>
<div class="col-xs-6 ptcontclock" id="questionclock">
<div class="positioner">
<h2>QUESTION CLOCK</h2>
</div>
</div>
<div class="col-xs-3 ptcontclock ptcontrol" id="ptcontrolB">
<div class="positioner">
<h2>CONTROL B</h2>
</div>
</div>
</div>
</div>
</body>
</html>
CSS:
.container-fluid {
width: 100vw;
height: 100vh;
}
#heading {
height: 15vh;
border: 2px solid;
}
#top-labels {
height: 10vh;
border: 2px solid;
width: 100vw;
}
#top-labels .labels {
border-right: 2px solid;
border-left: 2px solid;
}
#thirdrow {
height: 40vh;
border: 2px solid;
width: 100vw;
}
#thirdrow .pointsclock {
height: 40vh;
border-right: 2px solid;
border-left: 2px solid;
}
#fourthrow {
height: 35vh;
width: 100vw;
}
#fourthrow .ptcontclock {
border-right: 2px solid;
border-left: 2px solid;
height: 35vh;
}
.positioner{
height:100%;
width:100%;
position: relative;
top: 50%;
transform: translateY(-50%);
}
You can try this.
HTML
<main>
<div>
I'm a block-level element with an unknown height, centered vertically
within my parent.
</div>
</main>
CSS
body {
background: #f06d06;
font-size: 80%;
}
main {
background: white;
height: 300px;
width: 200px;
padding: 20px;
margin: 20px;
display: flex;
flex-direction: column;
justify-content: center;
resize: vertical;
overflow: auto;
}
main div {
background: black;
color: white;
padding: 20px;
resize: vertical;
overflow: auto;
}
<main>
<div>
I'm a block-level element with an unknown height, centered vertically within my parent.
</div>
</main>
check this link for reference https://css-tricks.com/centering-css-complete-guide/
The Above image shows this is how i want to make it.I have alignment display issue and line doesn't gets displayed. how can i achieve using with bootstrap grid.I want it make responsive. please advise where i am making mistake and how can i make it happen.
plunker link
I wan to see like this
<div class="container-fluid" style="background: white;">
<div class="row">
<div class="col-lg-9 col-xs-12 ">
<div class="parent col-md-3 col-xs-3">
<div class="child circle col-md-1 col-xs-1">1</div>
<div class="expenseItems col-md-1 col-xs-1">Text1</div>
<div class="hrcol-md-1 col-xs-1"></div>
</div>
<div class="parent col-md-3 col-xs-3">
<div class="child circle col-md-1 col-xs-1">2</div>
<div class="expenseItems col-md-2 col-xs-2">Text2</div>
<div class="hr col-md-1 col-xs-1"></div>
</div>
<div class="parent col-md-3 col-xs-3">
<div class="child circle col-md-1 col-xs-1">3</div>
<div class="expenseItems col-md-2 col-xs-2">Text3</div>
<div class="hr col-md-1 col-xs-1"></div>
</div>
<div class="parent col-md-3 col-xs-3">
<div class="child circle col-md-1 col-xs-1">4</div>
<div class="expenseItems col-md-2 col-xs-2">Text4</div>
<div class="hr col-md-1 col-xs-1"></div>
</div>
</div>
</div>
CSS
/*For drawing line*/
.hr {
color: gray;
background: gray;
width: 5px;
height: 1px;
margin-top:4px;
}
.circle
{
width: 28%;
border-radius: 100%;
text-align: center;
font-size: 14pt;
padding: 1pt;
position: relative;
background: gray;
color: white;
margin-top:11pt;
}
/*Parent div*/
.parent {
border-style: dashed;
border-width: 1px;
padding: 25px;
display:inline-block;
background-color:Aqua;
}
.child {
float: left;
background-color:Orange;
}
.expenseItems {
display: inline-block;
background-color:Green;
}
Using columns to acheive alignment inside other columns doesn't really make much sense when you can simply use a display property to do this with the content inside a column.
Use display: inline-block and remove all the nested columns.
Working Example: Open at FullPage
/*Use this rule below adjust the space between columns*/
.no-gutter > [class*='col-'] {
padding-right: 1px;
padding-left: 1px;
}
/*Use the above to adjust the space between columns*/
.parent {
border: 1px dashed red;
padding: 20px 25px 25px;
}
.circle {
width: 25px;
height: 25px;
border-radius: 50%;
padding-top: 3px;
display: inline-block;
text-align: center;
background-color: red;
color: white;
}
.expenseItems {
padding: 10px;
display: inline-block;
color: red;
}
.hr {
background: red;
height: 2px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="container-fluid">
<div class="row no-gutter">
<div class="col-sm-3">
<div class="parent">
<div class="circle">1</div>
<div class="expenseItems">TEXT</div>
<div class="hr"></div>
</div>
</div>
<div class="col-sm-3">
<div class="parent">
<div class="circle">1</div>
<div class="expenseItems">TEXT</div>
<div class="hr"></div>
</div>
</div>
<div class="col-sm-3">
<div class="parent">
<div class="circle">1</div>
<div class="expenseItems">TEXT</div>
<div class="hr"></div>
</div>
</div>
<div class="col-sm-3">
<div class="parent">
<div class="circle">1</div>
<div class="expenseItems">TEXT</div>
<div class="hr"></div>
</div>
</div>
</div>
</div>
When using bootstrap to build the base of a website it creates some weird black, the black color is the body's color, margin on the right side of the header.
HTML:
<section id="header">
<div class="row">
<div class="content-wrapper">
<div class="col-md-6">
<div class="left">
<img src="#" alt="">
</div>
</div>
<div class="col-md-6">
<div class="right">
<nav>
<ul>
<li>a</li>
<li>b</li>
<li>c</li>
</ul>
</nav>
</div>
</div>
</div>
</div>
</section>
<section id="featured">
<div class="row">
<div class="col-md-4 box yellow">
</div>
<div class="col-md-4 box blue">
</div>
<div class="col-md-4 box red">
</div>
</div>
<div class="row">
<div class="col-md-4 box green">
</div>
<div class="col-md-4 box gray">
</div>
<div class="col-md-4 box white">
</div>
</div>
</section>
CSS:
body {
background: #000;
}
.content-wrapper {
max-width: 1100px;
margin: 0 auto;
}
.left {
float: left;
}
.right {
float: right;
}
section#header {
background: white;
height: 150px;
}
nav ul li {
display: inline-block;
}
.yellow {
background: yellow;
}
.red {
background: red;
}
.blue {
background: blue;
}
.green {
background: green;
}
.gray {
background: gray;
}
.white {
background: white;
}
.box {
height: 250px;
}
Here's a jsfiddle: http://jsfiddle.net/awu2cp6a/
The black on the right side is the background color.
The reason you only see it there is, because .row has margin-left/right: 15px;. If you remove/overwrite this to 0px, the black disappears or you add the row class to the element with the image.
EDIT
So if you would have an image, it would be OVER the black area, but because there is no image that fits in the full size, it's not displaying. Have you tryed give your section the row class?