I want to place it like this:
this my code so far, but nothing of what I tried actually works:
what am I doing wrong?
#container {
text-align : center;
}
.button {
border : none;
color : rgba(93, 24, 172, 0.603);
padding : 15px 15px;
text-align : center;
text-decoration : none;
display : inline-block;
font-size : 10px;
margin : 10px 2px;
cursor : pointer;
position : absolute;
}
.button1 {
background-color : white;
}
/* added to see white text */
body { background : darkblue; }
<pre style="font-family:Calibri; color:white;text-align:left;">
Duis aute irure dolor in reprehenderit in voluptare
velit esse cillum dolore eu fugiat nulla pariatur.
Exceptur sint occaecat cupidatat non proident, sunt
in culpa qui officia deserunt mollit anim id est.
</pre>
<div text-align="center">
<button class="button button1" style="text-align:right;">READ MORE</button>
</div>
Any help is welcome. Thanks!
#container {
text-align : center;
}
.button {
border : none;
color : rgba(93, 24, 172, 0.603);
padding : 15px 15px;
text-align : center;
text-decoration : none;
display : inline-block;
font-size : 10px;
margin : 15px 10px;
cursor : pointer;
}
.button1 {
background-color : white;
}
/* added to see white text */
body { background : darkblue; }
pre{
display:inline-block;
text-align:left;
margin:0 auto;}
<div id="container">
<pre style="font-family:Calibri; color:white;border: 1px solid white;">
Duis aute irure dolor in reprehenderit in voluptare
velit esse cillum dolore eu fugiat nulla pariatur.
Exceptur sint occaecat cupidatat non proident, sunt
in culpa qui officia deserunt mollit anim id est.</pre>
<div text-align="center">
<button class="button button1" style="text-align:right;">READ MORE</button>
</div>
</div>
The main issue with your code is that button has an absolute position so it was removed from the normal document flow. Also depending on your website, you would need some sort of layout, or container around the button and text to keep them together.
I moved the button under the text and made a container for them. I also removed some unnecessary css and html you had, like the div around the button.
body {
background: #496bbe
}
.Container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: fit-content;
}
.button {
border: none;
color: rgba(93, 24, 172, 0.603);
padding: 15px 15px;
font-size: 10px;
cursor: pointer;
}
.button1 {
background-color: white;
}
pre {
font-family: "Gill Sans", "Gill Sans MT", Calibri, "Trebuchet MS", sans-serif;
color: white;
text-align: left;
white-space: pre-wrap;
}
<section class="Container">
<pre>
Duis aute irure dolor in reprehenderit in voluptare
velit esse cillum dolore eu fugiat nulla pariatur.
Exceptur sint occaecat cupidatat non proident, sunt
in culpa qui officia deserunt mollit anim id est.</pre>
<button class="button button1" style="text-align:right;">READ MORE</button>
</section>
Related
If I have one grid item (child) it spans 100% of it's container. If I add another, they'll be 50% and side by side (as intended).
If I add another, so it wraps, it stays at 50%, aligning with the first child above. Is it possible for this item to span the width of the container unless another item is added to the grid?
The reason I'm using grid is because I have these responsive/scalable flip/flashcards on click. So if the heights vary they still align nicely (code included).
Also a CodePen which might be easier to view due to viewport width: https://codepen.io/moy/pen/JjvPRgz
It this possible or would I need to compromise/look at a solution using flex maybe?
$('.flashcard').click(function() {
$(this).toggleClass('flipped');
});
/**
* Mixin
*/
/**
* Properties
*/
:root {
--btn-primary-bg: rgb(41, 174, 229);
--btn-primary-color: rgb(255, 255, 255);
--btn-primary-box-shadow: inset -8px -4px 0 rgba(0, 0, 0, 8%), 2px 2px 0 rgba(0, 0, 0, 8%);
--btn-primary-text-shadow: 1px 1px 0 rgba(0, 0, 0, 24%);
}
/**
* Base
*/
body {
box-sizing: border-box;
font-family: helvetica;
margin: 0 auto;
padding: 24px;
max-width: 800px;
}
h4, p {
font-size: 14px;
margin: 0;
padding: 0;
}
/**
* Flashcards
*/
.flashcard-wrap {
display: grid;
grid-template-columns: 1fr;
grid-gap: 12px;
grid-auto-rows: 1fr;
margin-bottom: 24px;
}
#media (min-width : 64em) {
.flashcard-wrap {
grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
}
}
.flashcard {
cursor: -webkit-grab;
cursor: grab;
display: flex;
perspective: 40rem;
transition: z-index, transform 0.24s;
transition-delay: 0.24s, 0s;
z-index: 0;
}
.flashcard.flipped {
transition-delay: 0s;
z-index: 1;
}
.flashcard:active {
cursor: -webkit-grabbing;
cursor: grabbing;
transform: scale(0.8);
}
.flashcard :last-child {
margin-bottom: 0;
}
.flashcard .bubble {
margin-bottom: 12px;
}
.flashcard__inner {
display: flex;
flex: 1;
transform-style: preserve-3d;
transition: 0.24s transform;
}
.flashcard.flipped .flashcard__inner {
transform: rotateX(-180deg);
}
.flashcard__front,
.flashcard__back {
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
background-color: white;
box-sizing: border-box;
padding: 1.5rem;
border-radius: 0.25rem;
background: var(--btn-primary-bg);
box-shadow: var(--btn-primary-box-shadow);
backface-visibility: hidden;
border-radius: 12px;
box-sizing: border-box;
color: var(--btn-primary-color);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: 14px;
padding: 24px;
min-width: 100%;
}
.flashcard__back {
transform: rotateX(-180deg) translate(-100%, 0);
}
.flashcard__back--left-align {
align-items: flex-start;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="flashcard-wrap">
<div class="flashcard">
<div class="flashcard__inner">
<div class="flashcard__front">
<h4 class="flashcard__title">Heading #1</h4>
</div>
<div class="flashcard__back">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
</div>
</div>
<div class="flashcard">
<div class="flashcard__inner">
<div class="flashcard__front">
<h4 class="flashcard__title">Heading #2</h4>
</div>
<div class="flashcard__back">
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
</div>
<div class="flashcard">
<div class="flashcard__inner">
<div class="flashcard__front">
<h4 class="flashcard__title">Heading #3</h4>
</div>
<div class="flashcard__back">
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
</div>
</div>
Wanna show the divs beside together?
you can use flex-wrap property for container and set it to nowrap as the default is.
Hope it was helpful.
This is possible with CSS alone. You do not need to change much of your existing code – just tweaking your grid for desktop and adding an extra line.
As you want two columns in your grid when there is more than one card we can simplify your grid so it is fixed to two columns. The only time a card needs to span the whole width of the container is if there are an odd number of flashcards (including when there is just a single flashcard). You also know you only want the last flashcard to span the whole width. On that basis we target each of those in order. To your flashcard-wrap class you need to add the following:
.flashcard-wrap {
//existing code
#include bp(bp5) {
grid-template-columns: repeat(2,1fr); // change to existing code so we always have two columns available.
& > *:nth-child(odd):last-child { // this will target the last flashcard but only if there are an odd number of cards - that includes the situation of there only being one card
grid-column: span 2;
}
}
}
NB: I have used the universal selector * as that will give you the flexibility to add different elements there if you need to. You can just as easily swap out * for .flashcard though if you only want the rule applied to flashcards.
I'm creating a website using CSS and HTML as part of a school assignment and I cannot figure out how to get my text and image neatly aligned on the center of the page. Example of what I want: https://chagaimweiss.com/
I've been looking up solutions on line but nothing's worked and my code is just confusing me even more. (I've never done this before, I'm an absolute beginner.) I'm posting the entire code just because I'm afraid some element might be messing up others.
html {
font-size: 100%;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%
}
body {
margin: 0;
font-size: 13px;
line-height: 1.6em
}
ul {
list-style: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: white;
text-align: center;
}
li {
display: inline;
}
li a {
display: inline-block;
color: grey;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover {
background-color: #f3f3f3;
display: inline-block;
padding: 10px;
}
h1 {
font-family: Helvetica;
font-size: 80px;
font-weight: 400;
text-align: center;
}
img {
width: 400px;
border-radius: 70%;
}
center {
display: block;
margin-left: auto;
margin-right: auto;
width: 50%;
}
p {
overflow: hidden;
float: right;
clear: both;
}
.box {
display : flex;
justify-content : center;
align-items : center;
margin-left : 25px;
margin-right : 25px;
}
.text {
margin-right: 200px;
margin-left: 50px;
}
<html lang="en">
<head>
<title>TITLE</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<ul>
<li>Home</li>
<li>Resume</li>
<li>Contact</li>
</ul>
<h1>Title</h1>
<div class="box">
<center>
<img src="Profile_photo.jpg" alt="Profile Photo"/>
<span style="p" class="text">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
<br>
<br>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</span>
</center>
</div>
</body>
</html>
This might be what your are searching for
.container {
display: flex; /* <--- This does the trick */
max-width: 860px; /* Limit the width */
margin: 0 auto; /* Centering the container */
font-size: 22px;
line-height: 2;
}
.responsive {
max-width: 100%;
height: auto;
}
.image-section {
width: 50%;
/* background: #3C86FF; */
}
.text-section {
width: 50%;
padding: 14px;
/* background: #8D3CFF; */
}
<div class="container">
<div class="image-section"><img class="responsive" src="https://i.imgur.com/GuAB8OE.jpg" /></div>
<div class="text-section">Lorem, ipsum dolor sit amet consectetur adipisicing elit. Recusandae adipisci ipsam eius sit nobis iure exercitationem officia quos earum eligendi?</div>
</div>
You can use this code
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<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">
<title>index</title>
<style type="text/css">
html {
font-size: 100%;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%
}
body {
margin: 0;
font-size: 13px;
line-height: 1.6em
}
ul {
list-style: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: white;
text-align: center;
}
li {
display: inline;
}
li a {
display: inline-block;
color: #333;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 18px;
font-weight: 400;
}
li a:hover {
background-color: #f3f3f3;
display: inline-block;
padding: 14px 16px;
}
h1 {
font-family: Helvetica;
font-size: 90px;
font-weight: 400;
text-align: center;
margin: 30px;
padding: 0;
}
img {
width: 400px;
height: 400px;
border-radius: 100%;
}
p {
overflow: hidden;
float: right;
clear: both;
}
.box {
display: flex;
justify-content: center;
align-items: center;
}
.text {
text-align: left;
font-size: 17px;
line-height: 26px;
font-weight: 500;
color: #333;
}
center {
width: 100%;
min-height: 300px;
margin: 0 auto;
display: -webkit-flex;
display: flex;
}
center .text {
padding: 0;
-webkit-flex: 1;
-ms-flex: 1;
flex: 1;
}
#media only screen and (max-width: 768px) {
.text {
text-align: left;
font-size: 14px;
line-height: 18px;
font-weight: 500;
color: #333;
}
img {
width: 330px;
height: 330px;
border-radius: 100%;
}
}
#media only screen and (max-width: 767px) {
.text {
text-align: left;
font-size: 13px;
line-height: 16px;
font-weight: 500;
color: #333;
}
img {
width: 200px;
height: 200px;
border-radius: 100%;
}
}
</style>
</head>
<body>
<div class="container">
<ul>
<li>Home</li>
<li>Resume</li>
<li>Contact</li>
</ul>
<h1>Title</h1>
<div class="box">
<center>
<span class="text">
<img src="https://images.squarespace-cdn.com/content/v1/5bda793b0dbda3f980201462/1541898879554-U3DFRQS8QDCYCCHNICSG/ke17ZwdGBToddI8pDm48kE18-4zwLU-qbiNthgfATgZ7gQa3H78H3Y0txjaiv_0fDoOvxcdMmMKkDsyUqMSsMWxHk725yiiHCCLfrh8O1z5QPOohDIaIeljMHgDF5CVlOqpeNLcJ80NK65_fV7S1Ue5QMtRsKNQ0Y8f36XeapJ7hOyTFdhnyFq38bJ63oibyFlq8oZZwhhoTbTOjCpwBwg/chagaiweiss.jpeg" alt="Profile Photo" />
</span>
<span class="text">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
<br>
<br>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</span>
</center>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>
I have some code snippets on my blog post here.
There I have custom scrollbar defined with this code below:
/* width */
::-webkit-scrollbar {
width: 20px;
}
/* Track */
::-webkit-scrollbar-track {
box-shadow: inset 0 0 5px grey;
border-radius: 10px;
}
/* Handle */
::-webkit-scrollbar-thumb {
background: #0ef;
border-radius: 10px;
}
The place where I have included the snippet is a custom div element with border radius of 2em. Now the custom scrollbar looks some bulged out as you can see in the image below:
How can I send the scrollbar behind the <div> so that the extra scrollbar may be removed?
P.S.: The border radius of the <div> should be maintained.
You can put a small div inside your outer div and make that the container of your scroll bar to stop the bulging out of these scroll bars eg. fiddle like
<div class="outer">
<div class="inner">
..content
</div>
</div>
.outer{
max-height:200px;
width:250px;
border-radius:10px;
padding:0px 0px;
background:#ccc;
}
.inner{
white-space: nowrap;
width:250px;
max-height:200px;
overflow-x:scroll;
overflow-y:hidden;
border-radius:8px;
}
/* width */
::-webkit-scrollbar {
width: 20px;
}
/* Track */
::-webkit-scrollbar-track {
box-shadow: inset 0 0 5px grey;
border-radius: 10px;
}
/* Handle */
::-webkit-scrollbar-thumb {
background: #0ef;
border-radius: 10px;
}
<div class="outer">
<div class="inner">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</div>
</div>
I have started making a grid and each row has a class ".row" and inside that are classes with .col-3-12 for the width of the div and they float left what I want to do is create a class called .centred and have that inner div that is floated centred. At the moment it centre's the div at 50% it need's a -50% somewhere to make it in the middle codepen
<div class="row">
<div class="col-3-12 centered">
Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
</div>
.row [class*="col-"].centred {
left: 50%;
}
.col-3-12 {
width: 23.5%;
}
Try adding a negative margin-left as below:
.row [class*="col-"].centred {
left: 50%;
}
.col-3-12 {
width: 23.5%;
margin-left:-11.75%;
}
I have a page that looks like this:
box-shadow http://www.morninj.com/images/box-shadow-screenshot.png
The middle div (with "Quotation." as its contents) has a box-shadow property applied. For some reason, the shadow won't appear below the second div if the third div is present. Does anybody know why?
HTML:
<div id="header">
<h1>Title</h1>
</div><!--/#header-->
<div id="subheader">
<h2>"Quotation."</h2>
</div><!--/#subheader-->
<div id="blurb">
<div id="blurb-container">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div><!--/#blurb-container-->
</div><!--/#blurb-->
CSS:
div#header {
background-color: #444;
padding: 20px 0;
}
div#header h1 {
color: #fff;
font-family: 'Arvo', sans-serif;
font-size: 50px;
font-weight: bold;
text-align: center;
text-shadow: 1px 1px 1px #000;
}
div#subheader {
background-color: #777;
box-shadow: 0 0 3px 2px #333;
padding: 10px;
}
div#subheader h2 {
color: #efefef;
font-family: 'Merriweather', serif;
font-size: 14px;
font-style: italic;
line-height: 24px;
text-align: center;
}
div#blurb {
background-color: #efefef;
padding: 20px;
}
div#blurb div#blurb-container {
margin: 0 auto;
width: 800px;
}
Your 'blurb' is covering it up. Edit the div#blurb css rule to the following to move it behind the shadowed div:
div#blurb {
background-color: #efefef;
padding: 20px;
position:relative;
z-index:-1;
}
Set the position of both elements to relative and the z-index of the first one to 1 and the lower one to 0.
Edit: yes, negative values are allowed :). But they don't work in firefox 2.