here is my index.html:
<div id="container1" class="py-0 my-0">
<div id="left" class="col-md-6">
<img class="image" src="C:\Users\asus\Desktop\project\image.png">
</div>
<div id="right" class="col-md-6">
<nav class="navbar navbar-expand-lg">
<ul class="navbar-nav ml-auto">
<li class="nav-index">
HOME
</li>
<li class="nav-index">
ABOUT US
</li>
<li class="nav-index">
COURSES
</li>
<li class="nav-index">
LOG IN
</li>
</ul>
</nav>
<br>
<br>
<br>
<br>
<br>
<p class="paragraph col-md-6">
<h3 class="Welcome text-center">Welcome to mobile legends!</h3>
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>
<br>
<br>
<footer class="footer1" id="footer1">
<h6>Contact the developer:</h6>
<p>luckyllemos0909#gmail.com</p>
</footer>
</div>
</div>
here is my style.css:
*{
box-sizing: border-box;
margin: 0;
padding: 0;
}
html, body{
width: 100%;
height: 100%;
padding: 0;
margin: 0;
align-items: center;
vertical-align: middle;
}
#container1{
width: 100%;
height: 100%;
vertical-align: middle;
display: flex;
align-items: center;
}
#left,
#right {
width: 50%;
height: 100%;
}
#left {
background: #ffd6dd;
align-items: center;
}
.image{
margin-top: 50px;
margin-left: -10px;
padding: 100px;
}
#right {
background: #FBAED2;
align-items: center;
}
.paragraph{
color: red;
margin: 50px;
}
.fa {
margin-top: none;
padding: 20px;
font-size: 20px;
width: 30px;
text-align: center;
text-decoration: none;
margin: 5px 2px;
}
.fa:hover {
opacity: 0.7;
}
.fa-facebook {
color: #000000;
}
.fa-linkedin {
color: #000000;
}
.fa-youtube {
color: #000000;
}
.Welcome{
margin-left:60px;
}
.nav-link{
color: #000000;
}
.nav-index{
padding-left: 30px;
padding-right: 30px;
align-items: center;
}
my problem is when i put it in mobile phone it does not go flexible.
This is the original output:
and This what happens when try to look on mobile screen:
What you're looking for is media queries, which let you decide how your website looks on varying screen sizes. In the example below in the css class example is first shown how it would look on a larger screen size, then below with the media query in effect you can stylize how your page would look on a (in this example) a screen with a width of less than 900px. Take a look at the link below for further explanation.
.example {
font-family: "Droid+Sans";
font-weight: normal;
color: #ffffff ;
font-size: 7rem;
position: absolute;
top: 17%;
width: 100%;
}
#media screen and (max-width: 900px){
.example {
font-size: 3.5rem;
margin: auto;
width: 50%;
left: 20%;
right: 20%;
padding-bottom: 100px;
}
}
https://www.w3schools.com/css/css_rwd_mediaqueries.asp
Use Bootstrap Utility Classes in a better way. Since you are using bootstrap simply add your classes to work for different break points.
Add col-12 Utility classes on the following elements: Note that Bootstrap follows mobile-first approach.
<div id="left" class="col-12 col-md-6">
And
<div id="right" class="col-12 col-md-6">
I'd like to simulate a "scan" light that will reveal words in a box, this is my code by now:
const e = document.getElementsByClassName('scan')[0];
document.onmousemove = function(event){
e.style.left = `${event.clientX}px`;
};
*{
margin: 0;
padding: 0;
}
html, body{
width: 100%;
min-height: 100vh;
overflow-x: hidden;
display: flex;
}
.banner{
width: 100vw;
height: 100vh;
display: flex;
flex-grow: 1;
flex-direction: row;
align-items: center;
background-color: #031321;
}
.banner .scan{
width: 7px;
height: 80%;
position: absolute;
left: 30px;
z-index: 3;
transition: left 50ms ease-out 0s;
border-radius: 15px;
background-color: #fff;
box-shadow:
0 0 15px 5px #fff, /* inner white */
0 0 35px 15px #008cff, /* inner blue */
0 0 350px 20px #0ff; /* outer cyan */
}
.banner .description{
width: 100%;
color: white;
font-size: 3em;
text-align: center;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
<div class="banner">
<div class="scan"></div>
<div class="description">
Just trying something
</div>
</div>
The idea is the show the words in the .description div according to the scan light position. If possible I'd like to use CSS only to make this effect, and use JavaScript only to move the scan (which will further become a CSS animation). I tried to use some pseudo elements, but it didn't work well. Here's an example of how this animation should work.
You can use transparent text with gradient background. I used background-attachment: fixed and a CSS variable to control background position.
You can increase the background-size (500px in this example) to increase transition smoothing.
const e = document.getElementsByClassName('scan')[0];
const hidden = document.getElementsByClassName('hidden')[0];
document.onmousemove = function(event) {
e.style.left = `${event.clientX}px`; // ↓ background width (500px) / 2
hidden.style.setProperty("--pos", `${event.clientX - 250}px`);
};
* {
margin: 0;
padding: 0;
}
html,
body {
width: 100%;
min-height: 100vh;
overflow-x: hidden;
display: flex;
}
.banner {
width: 100vw;
height: 100vh;
display: flex;
flex-grow: 1;
flex-direction: row;
align-items: center;
background-color: #031321;
}
.banner .scan {
width: 7px;
height: 80%;
position: absolute;
left: 30px;
z-index: 3;
transition: left 50ms ease-out 0s;
border-radius: 15px;
background-color: #fff;
box-shadow: 0 0 15px 5px #fff, /* inner white */
0 0 35px 15px #008cff, /* inner blue */
0 0 350px 20px #0ff;
/* outer cyan */
}
.banner .description {
width: 100%;
color: white;
font-size: 3em;
text-align: center;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
.hidden {
background: radial-gradient(dodgerblue 10%, #031321 50%) var(--pos) 50% / 500px 500px no-repeat fixed;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
<div class="banner">
<div class="scan"></div>
<div class="description">
Just <span class="hidden">hidden</span> something
</div>
</div>
Here is another example with very long paragraph and multiple hidden text. We control both X and Y axis in here.
const hiddens = document.querySelectorAll('.hidden');
document.addEventListener("mousemove", e => {
hiddens.forEach(p => {
// ↓ background width (400px) / 2
p.style.setProperty("--posX", `${e.clientX - 200}px`);
p.style.setProperty("--posY", `${e.clientY - 200}px`);
});
});
html,
body {
width: 100%;
overflow-x: hidden;
}
body {
background: #031321;
color: #fff;
font-size: 3rem;
line-height: 1.5;
padding: 20px;
box-sizing: border-box;
}
.hidden {
background: radial-gradient(dodgerblue 10%, #031321 50%) var(--posX) var(--posY) / 400px 400px no-repeat fixed;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
Lorem ipsum dolor sit amet, <span class="hidden">consectetur</span> 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. <span class="hidden">Excepteur sint</span> occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. 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. 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. 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 <span class="hidden">commodo</span> 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. 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.
Here is an idea using transformation to have better performance
document.onmousemove = function(event){
document.body.style.setProperty("--p", `${event.clientX}px`);
};
body{
margin: 0;
overflow:hidden;
}
.banner{
height: 100vh;
display: flex;
align-items: center;
background-color: #031321;
}
.banner::before{
content:"";
width: 7px;
height: 80%;
position: absolute;
left: 0;
transform:translateX(var(--p,30px));
z-index: 3;
transition: transform 50ms ease-out 0s;
border-radius: 15px;
background-color: #fff;
box-shadow:
0 0 15px 5px #fff, /* inner white */
0 0 35px 15px #008cff, /* inner blue */
0 0 350px 20px #0ff; /* outer cyan */
}
.banner .description{
color: white;
font-size: 3em;
text-align: center;
width:100%;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
overflow:hidden;
position:relative;
}
.banner .description::before {
content:"";
position:absolute;
top:0;
right:0;
bottom:0;
width:200%;
background:linear-gradient(to right,#031321 40%,transparent,#031321 60%);
transform:translateX(var(--p,0px));
}
<div class="banner">
<div class="description">
Just trying something
</div>
</div>
To apply it to only few words, you play with z-index
document.onmousemove = function(event){
document.body.style.setProperty("--p", `${event.clientX}px`);
};
body{
margin: 0;
overflow:hidden;
}
.banner{
height: 100vh;
display: flex;
align-items: center;
background-color: #031321;
}
.banner::before{
content:"";
width: 7px;
height: 80%;
position: absolute;
left: 0;
transform:translateX(var(--p,30px));
z-index: 3;
transition: transform 50ms ease-out 0s;
border-radius: 15px;
background-color: #fff;
box-shadow:
0 0 15px 5px #fff, /* inner white */
0 0 35px 15px #008cff, /* inner blue */
0 0 350px 20px #0ff; /* outer cyan */
}
.banner .description{
color: white;
font-size: 3em;
text-align: center;
width:100%;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
overflow:hidden;
position:relative;
z-index:0;
}
.banner .description::before {
content:"";
position:absolute;
z-index:-1;
top:0;
right:0;
bottom:0;
width:200%;
background:linear-gradient(to right,#031321 40%,transparent,#031321 60%);
transform:translateX(var(--p,0px));
}
.banner .description > span {
position:relative;
z-index:-2;
color:lightblue;
font-weight:bold;
}
<div class="banner">
<div class="description">
Just <span>trying</span> something <span>cool</span>
</div>
</div>
Another idea to make it working with any background in case you want transparency:
document.onmousemove = function(event){
document.body.style.setProperty("--p", `${event.clientX}px`);
};
body{
margin: 0;
overflow:hidden;
}
.banner{
height: 100vh;
display: flex;
align-items: center;
justify-content:center;
color: white;
font-size: 3em;
background: url(https://picsum.photos/id/1018/800/800) center/cover;
position:relative;
z-index:0;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
.banner::before{
content:"";
width: 7px;
height: 80%;
position: absolute;
left: 0;
transform:translateX(var(--p,30px));
z-index: 3;
transition: transform 50ms ease-out 0s;
border-radius: 15px;
background-color: #fff;
box-shadow:
0 0 15px 5px #fff, /* inner white */
0 0 35px 15px #008cff, /* inner blue */
0 0 350px 20px #0ff; /* outer cyan */
}
.banner::after {
content:"";
position:absolute;
z-index:-1;
top:0;
right:0;
bottom:0;
left:0;
background:inherit;
-webkit-mask:
linear-gradient(to right,#fff 45%,transparent,#fff 55%)
right calc(-1*var(--p,0px)) top 0/200% 100% no-repeat;
}
.banner > span {
position:relative;
z-index:-2;
color:red;
font-weight:bold;
}
<div class="banner">
Just <span>trying</span> something <span>cool</span>
</div>
Cool glow stick!
I'm assuming that this is for a logo, and that the text should continue to be shown when the glow stick has passed the text.
I would use a pseudo-element on the description element, place it on top and use a gradient-background going from transparent to the darkblue background color. By using a gradient, you can achieve a nice fade in of the text.
I would then set the starting point of the dark background color with a CSS variable that I update through your onmousemove method.
The code doesn't take different screen sizes into account, so you probably need to convert pixels to percentage, if you want your animation to be responsive.
I also changed your classes to id. I think it's more appropriate to show, by using ids, that the element is somehow used by javascript. It's easier to bind the elements to variables too.
const scanEl = document.getElementById('scan');
const descEl = document.getElementById("description")
document.onmousemove = function(event){
let descriptionDisplacement = 100;
scanEl.style.left = `${event.clientX}px`;
descEl.style.setProperty("--background-shift", `${event.clientX + descriptionDisplacement}px`);
};
*{
margin: 0;
padding: 0;
}
html, body{
width: 100%;
min-height: 100vh;
overflow-x: hidden;
display: flex;
}
.banner{
width: 100vw;
height: 100vh;
display: flex;
flex-grow: 1;
flex-direction: row;
align-items: center;
background-color: #031321;
}
.banner > #scan{
width: 7px;
height: 80%;
position: absolute;
left: 30px;
z-index: 3;
transition: left 50ms ease-out 0s;
border-radius: 15px;
background-color: #fff;
box-shadow:
0 0 15px 5px #fff, /* inner white */
0 0 35px 15px #008cff, /* inner blue */
0 0 350px 20px #0ff; /* outer cyan */
}
.banner > #description{
width: 100%;
color: white;
font-size: 3em;
text-align: center;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
/* ADDED */
--background-shift: 0px;
--background-shift-transparent: calc(var(--background-shift) - 150px);
position: relative;
}
.banner > #description::before {
content: '';
background: linear-gradient(to right, transparent var(--background-shift-transparent), #031321 var(--background-shift));
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
<div class="banner">
<div id="scan"></div>
<div id="description">
Just trying something
</div>
</div>
I just tried clipPath. Technically it does what you need but the performance of the animated clipPath is quite poor when combined with the glow effect (but much better without!). Possibly building the glow from something like an image instead of a box-shadow would improve this. (as could reducing the size of the outer most box shadow)
const e = document.getElementsByClassName('scan')[0];
const description = document.getElementsByClassName('description')[0];
document.onmousemove = function(event){
// comment out to compare performance
e.style.left = `${event.clientX}px`;
description.style.clipPath = `polygon(0 0, ${event.clientX}px 0, ${event.clientX}px 100%, 0 100%)`;
};
*{
margin: 0;
padding: 0;
}
html, body{
width: 100%;
min-height: 100vh;
overflow-x: hidden;
display: flex;
}
.banner{
width: 100vw;
height: 100vh;
display: flex;
flex-grow: 1;
flex-direction: row;
align-items: center;
background-color: #031321;
}
.banner .scan{
width: 7px;
height: 80%;
position: absolute;
left: 30px;
z-index: 3;
transition: left 50ms ease-out 0s;
border-radius: 15px;
background-color: #fff;
box-shadow:
0 0 15px 5px #fff, /* inner white */
0 0 35px 15px #008cff, /* inner blue */
0 0 350px 20px #0ff; /* outer cyan */
}
.banner .description{
width: 100%;
color: white;
font-size: 3em;
text-align: center;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
<div class="banner">
<div class="scan"></div>
<div class="description">
Just trying something
</div>
</div>
Try like this:
const e = document.getElementsByClassName('cover')[0];
e.addEventListener('click', animate);
function animate() {
e.classList.add('scanning');
}
*{
margin: 0;
padding: 0;
}
html, body{
width: 100%;
min-height: 100vh;
overflow-x: hidden;
display: flex;
}
.banner{
width: 100vw;
height: 100vh;
display: flex;
flex-grow: 1;
flex-direction: row;
align-items: center;
background-color: #031321;
}
.banner .cover{
position: absolute;
left: 30px;
z-index: 3;
height: 80%;
width:100vw;
background-color: #031321;
transition: left 700ms ease-out 0s;
}
.banner .cover.scanning {
left: calc(100% - 30px);
}
.banner .scan{
width: 7px;
height:100%;
transition: left 50ms ease-out 0s;
border-radius: 15px;
background-color: #fff;
box-shadow:
0 0 15px 5px #fff, /* inner white */
0 0 35px 15px #008cff, /* inner blue */
0 0 350px 20px #0ff; /* outer cyan */
}
.banner .description{
width: 100%;
color: white;
font-size: 3em;
text-align: center;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
<div class="banner">
<div class="cover">
<div class="scan">
</div>
</div>
<div class="description">
Just trying something
</div>
</div>
This solution uses a cover to the right of the scan with the same background colour as the banner. The cover moves with the scan, so when the scan moves to the right, it reveals the text on the left. It works by clicking on it in this demo, but you can initiate it in JavaScript however is best for you.
Seems a little tricky. The first solution that comes to mind is maybe using a linear gradient with a dynamic "stopping point" at the light bar position. The gradient goes from dark -> transparent (light bar position) -> dark. The code will maybe look something like:
.description-overlay {
/*
Replace 50% with the position of the light bar. Get brighter and more
transparent as you approach the position of the light bar.
*/
background: linear-gradient(to right, #000, 50% hsla(0, 0%, 100%, 0.2), #000);
}
Not sure if this will work and it would probably need a box-shadow thrown in somewhere, but maybe it'll give you some ideas.
I have a example exercise with a Sidebar Navigation that is fixed left of the screen.
I said that the content-div should have a position of absolute to the body and also a padding-left with the width of the sidebar, so that i can center my content in the visible area (width without the sidebar).
Now when I try to add a media query that says "when the screen is smaller than 1000px the Sidebar should disappear and the the padding of the content area should go to 0 (so that it gets centered in the normal screen width area)" it doesnt work.
I'm a beginner in html and css
Here is my code:
body {
font-family: 'Oswald', sans-serif;
padding: 0;
margin: 0;
background-color: #35af7e;
}
#media screen and (max-width: 1000px) {
.Sidebar {
left: -10rem;
}
.body {
padding-left: 0;
padding: 0;
}
}
#flex {
display: flex;
}
/* MEDIA QUERY FIX: NAVIC ; BODY-paddingleft ; */
.NavIc {
left: 1rem;
top: 1rem;
height: 30px;
width: 30px;
background-color: red;
border-radius: 3px;
z-index: 4;
position: fixed;
cursor: pointer;
}
.NavIc:hover .Sidebar {
background-color: red;
}
.Sidebar {
position: fixed;
width: 10rem;
height: 100%;
background: #E9D758;
color: white;
z-index: 3;
display: flex;
flex-direction: column;
transition: 200ms ease-in-out;
}
.space {
flex-grow: 1;
width: auto;
}
.Nav {
list-style-type: none;
display: block;
width: 100%;
padding: 0;
font-size: 1.5rem;
z-index: 2;
flex-grow: 18;
}
ul li {
box-sizing: border-box;
padding: 0.7rem 0 0.7rem 1rem;
position: relative;
transition: 150ms ease-in-out;
}
ul li:hover {
background-color: white;
color: black;
transform: scale(1.07) translate(0.3rem);
cursor: pointer;
}
.footnotes {
flex-grow: 1;
box-sizing: border-box;
padding: 0 1rem 0 1rem;
}
hr {
border-style: solid;
color: white;
}
.body {
position: absolute;
width: 100%;
padding-left: 10rem;
box-sizing: border-box;
top: 0;
color: white;
transition: 200ms ease-in-out;
}
.mid {
position: relative;
width: 60%;
left: 50%;
transform: translate(-50%);
font-size: 1.5rem;
}
.img {
position: relative;
max-width: 500px;
height: auto;
left: 50%;
transform: translate(-50%);
transition: 200ms ease-in-out;
}
.Logo {
position: relative;
left: 50%;
transform: translate(-50%);
max-width: 100%;
height: auto;
padding: 5rem 0 5rem 0;
}
.mid > hr {
width: 80%;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Sidebar</title>
<link rel="stylesheet" style="text/css" href="sidebar.css">
<link href="https://fonts.googleapis.com/css?family=Oswald" rel="stylesheet">
</head>
<body>
<div class="NavIc">
</div>
<div class="Sidebar">
<div class="space">
</div>
<ul class="Nav">
<li>Home</li>
<li>Gallery</li>
<li>Our Team</li>
<li>Contact</li>
</ul>
<div class="footnotes">
<hr>
<p>blablabla<br>
All rights reserved</p>
<p>blablabla</p>
</div>
</div>
<div class="body">
<div class="mid">
<div class="img">
<img src="Logo.svg" alt="Logo" class="Logo">
</div>
<hr>
<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.</p><p>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. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor.</p><p>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>
<hr>
</div>
</div>
</body>
</html>
Because your .body rule in #media (max-width: 1000px) is being override. Use !important or learn some CSS specificity/precedence.
body {
font-family: 'Oswald', sans-serif;
padding: 0;
margin: 0;
background-color: #35af7e;
}
#media screen and (max-width: 1000px) {
.Sidebar {
left: -10rem;
}
.body {
padding-left: 0 !important;
padding: 0;
}
}
#flex {
display: flex;
}
/* MEDIA QUERY FIX: NAVIC ; BODY-paddingleft ; */
.NavIc {
left: 1rem;
top: 1rem;
height: 30px;
width: 30px;
background-color: red;
border-radius: 3px;
z-index: 4;
position: fixed;
cursor: pointer;
}
.NavIc:hover .Sidebar {
background-color: red;
}
.Sidebar {
position: fixed;
width: 10rem;
height: 100%;
background: #E9D758;
color: white;
z-index: 3;
display: flex;
flex-direction: column;
transition: 200ms ease-in-out;
}
.space {
flex-grow: 1;
width: auto;
}
.Nav {
list-style-type: none;
display: block;
width: 100%;
padding: 0;
font-size: 1.5rem;
z-index: 2;
flex-grow: 18;
}
ul li {
box-sizing: border-box;
padding: 0.7rem 0 0.7rem 1rem;
position: relative;
transition: 150ms ease-in-out;
}
ul li:hover {
background-color: white;
color: black;
transform: scale(1.07) translate(0.3rem);
cursor: pointer;
}
.footnotes {
flex-grow: 1;
box-sizing: border-box;
padding: 0 1rem 0 1rem;
}
hr {
border-style: solid;
color: white;
}
.body {
position: absolute;
width: 100%;
padding-left: 10rem;
box-sizing: border-box;
top: 0;
color: white;
transition: 200ms ease-in-out;
}
.mid {
position: relative;
width: 60%;
left: 50%;
transform: translate(-50%);
font-size: 1.5rem;
}
.img {
position: relative;
max-width: 500px;
height: auto;
left: 50%;
transform: translate(-50%);
transition: 200ms ease-in-out;
}
.Logo {
position: relative;
left: 50%;
transform: translate(-50%);
max-width: 100%;
height: auto;
padding: 5rem 0 5rem 0;
}
.mid > hr {
width: 80%;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Sidebar</title>
<link rel="stylesheet" style="text/css" href="sidebar.css">
<link href="https://fonts.googleapis.com/css?family=Oswald" rel="stylesheet">
</head>
<body>
<div class="NavIc">
</div>
<div class="Sidebar">
<div class="space">
</div>
<ul class="Nav">
<li>Home</li>
<li>Gallery</li>
<li>Our Team</li>
<li>Contact</li>
</ul>
<div class="footnotes">
<hr>
<p>blablabla<br>
All rights reserved</p>
<p>blablabla</p>
</div>
</div>
<div class="body">
<div class="mid">
<div class="img">
<img src="Logo.svg" alt="Logo" class="Logo">
</div>
<hr>
<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.</p><p>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. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor.</p><p>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>
<hr>
</div>
</div>
</body>
</html>
Inside your media query use display: none;to hide the sidebar and then set padding: 0px;of your content. that's it.
#media only screen and (max-width: 1000px) {
.Sidebar{
display: none;
}
.body{
display: block;
padding: 0px;
}
}
I am unable to put " a:hover " on my home button in menu bar. even unable to remove the text-decoration.
while i was trying my hands on media queries , just got puzzled.
****stack overflow settings is not allowing me to post question unless i add more details*****
body {
background-image: url("blue-bokeh.jpeg");
width: 100%;
height: 100%;
}
.wrap {
height: auto;
width: 90%;
margin: auto;
}
header {
background: #333;
color: white;
height: auto;
width:100%;
float: left;
}
header nav {
width: 100%;
height: auto;
}
header nav ul {
list-style: none;
height: auto;
width: auto; /* what happens if i change the value to 100% */
float: right;
margin-right:30px;
}
header nav ul li {
display: inline;
padding: 15px 30px;
float: left;
border-radius: 5px;
}
header nav ul li a.active {
text-decoration: none;
}
header nav ul li:hover {
background-color: #111;
}
header nav ul li a.active:active {
background-color: #4caf50;
}
.mainbody {
/*background: tomato;*/ /* get the code checked , if its repeated in .top class */
float: left;
margin-top: 20px;
border-radius: 10px;
/*padding: 20px 20px;*/
height: auto;
width: 60%;
margin-right: 2%;
}
.top {
background: tomato;
margin-bottom: 10px;
float: left;
border-radius: 10px;
padding: 20px 20px;
}
.top h3 {
color: darkslategray
}
.bottom {
background: tomato;
margin-bottom: 50px;
float: left;
border-radius: 10px;
padding: 20px 20px;
}
.bottom h3 {
color: darkslategray
}
.sidebar {
float: left;
height: auto;
width: 38%;
margin-top: 20px;
}
.topside {
background: orangered;
margin-bottom: 10px;
border-radius: 10px;
padding: 20px 20px;
}
.middleside {
background: orangered;
margin-bottom: 10px;
border-radius: 10px;
padding: 20px 20px;
}
.bottomside {
background: orangered;
margin-bottom: 10px;
border-radius: 10px;
padding: 20px 20px;
}
footer {
background: darkslategray;
float: left;
width: 100%;
height: auto;
border-radius: 10px;
}
footer p {
padding-left: 50px;
}
/* ------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------MEDIA QUERY STARTS HERE---------------------------------------------------------------*/
#media screen and (max-width: 700px) {
body {
background-image: url("blue-bokeh.jpeg");
width: 100%;
height: 100%;
}
.wrap {
height: auto;
width: 90%;
margin: auto;
}
header {
background: #444;
color: white;
height: auto;
width:100%;
}
header nav {
width: 100%;
height: auto;
}
header nav ul {
list-style: none;
height: auto;
width: 100%; /* what happens if i change the value to 100% */
margin: 0;
padding: 0;
text-align: center;
}
header nav ul li {
display: block;
padding: 15px 30px;
float: none;
}
header nav ul li:hover {
background-color: #111;
}
header nav ul li a.active:active {
background-color: #4caf50;
}
.mainbody {
/*background: tomato;*/ /* get the code checked , if its repeated in .top class */
margin-top: 20px;
border-radius: 10px;
/*padding: 20px 20px;*/
height: auto;
width: 100%;
}
.top {
background: tomato;
margin-bottom: 10px;
border-radius: 10px;
padding: 20px 20px;
}
.top h3 {
color: darkslategray
}
.bottom {
background: tomato;
border-radius: 10px;
padding: 20px 20px;
}
.bottom h3 {
color: darkslategray
}
.sidebar {
height: auto;
width: 100%;
}
.topside {
background: orangered;
margin-bottom: 10px;
border-radius: 10px;
padding: 20px 20px;
}
.middleside {
background: orangered;
margin-bottom: 10px;
border-radius: 10px;
padding: 20px 20px;
}
.bottomside {
background: orangered;
margin-bottom: 10px;
border-radius: 10px;
padding: 20px 20px;
}
footer {
background: darkslategray;
float: left;
width: 100%;
height: auto;
border-radius: 10px;
}
footer p {
padding-left: 50px;
}
}
<!DOCTYPE html>
<html>
<head>
<title></title>
<link href="restheme.css" type="text/css" rel="stylesheet">
</head>
<body>
<div class="wrap">
<header>
<nav>
<ul>
<li><a class="active" href="#home">Home</a></li>
<li>Portfolio</li>
<li>Blog</li>
<li>Contact Us</li>
</ul>
</nav>
</header>
<div class="mainbody">
<article class="top">
<h3>First Post</h3>
<p>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</p>
</article>
<article class="bottom">
<h3>Second Post</h3>
<p>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</p>
</article>
</div>
<div class="sidebar">
<aside class="topside">
<h3>Top Sidebar</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</aside>
<aside class="middleside">
<h3>Middle Sidebar</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</aside>
<aside class="bottomside">
<h3>Bottom Sidebar</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</aside>
</div>
<footer>
<p>Copyright © 2016 Faltoo Webdesigns</p>
</footer>
</div>
</body>
</html>
If I understand you right, you want to achive something like this?
https://jsfiddle.net/j7j54Lta/1/
I did some improvements and changed the structure. The li gets the .active-class and not the anchor. If the anchor in the active li is hovered it changes the color (or whatever you want to achive):
header nav ul li.active a:hover{
color: red;
/* or whatever*/
}
Moreover there is no text-decoration:
header nav ul li.active a {
text-decoration: none;
cursor: default;
}
I want to use css to crop a square image like seen on the attached image. But also using the text on the right so how would I realize that whole container?
<div style="width:100%">
<div style="widht:50%; float:left">
My Texting
</div>
<div style="widht:50%; float:left">
<img src="myimage.png">
</div>
</div>
See fiddle here: https://jsfiddle.net/hgo62n6a/ How to crop the image?
Solution is here (edited, much cleaner now and flexible):
DEMO: jsFiddle
HTML:
<div class='section clearfix'>
<div class='section-content section-col section-col-left'>
<div class='padding'>
<p>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.</p>
</div>
</div> <!-- end of .section-content -->
<div class='section-bar clearfix'>
<table>
<tr>
<td><a href=''>item 1</a></td>
<td><a href=''>item 2</a></td>
<td><a href=''>item 3</a></td>
</tr>
</table>
</div> <!-- end of .section-bar -->
<div class='section-bg' style='background-image: url("http://www.ysecit.com/css/images/bg-original.jpg")'> </div>
CSS:
*{
padding: 0;
margin: 0;
text-decoration: none;
box-sizing: border-box
}
.clearfix {
display: table;
}
.clarfix ::after{
content: "";
display: block;
clear: both;
}
.padding{
padding: 40px;
}
.section {
position:relative;
overflow: hidden;
}
.section-col{
}
.section-col-left {
float: left
}
.section-content {
width: 50%;
left: 0;
z-index: 3;
position: relative;
}
.section-content::before {
display: block;
width: 0;
content: "";
position: absolute;
top: 0;
right: -40px;
border: 1000px solid #fff;
border-right: 200px solid transparent;
z-index: 2;
}
.section-content div {
position: relative;
z-index: 3;
}
.section-bg {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
background-size: cover;
background-position: top right;
background-repeat: no-repeat;
}
.section-bar {
position: absolute;
bottom: 0;
width: 100%;
background: #000;
z-index: 2
}
.section-bar table {
float: right;
}
.section-bar table tr td {
padding: 10px
}
.section-bar table tr td a{
color: #fff
}
Use this CSS:
img {
position: absolute;
clip: rect(0px,60px,200px,0px);
}
The format for the clip attribute is as follows:
clip: rect(top, right, bottom, left);
please refer this one:
.holder {
width: 200px;
height: 200px
}
.holder:before {
content:"";
width: 0px;
height: 0px;
border-top: 20px solid transparent;
border-left: 20px solid transparent;
border-right: 20px solid white;
border-bottom: 20px solid white;
position:absolute;
top: 169px;
left: 169px;
}
img {
width: 100%;
height: 100%;
}
DEMO
Hope this will help you..
Here is Html code:
<div style="width:100%">
<div style="widht:50%;float:left;
background-color:#efefef;
height:200px
;width:300px;" class="cutCorner">
My Texting
</div>
<div style="widht:50%; float:left;" >
<img style=height:200px;width:300px;"
src="http://www.mobilo-med.de/uploads/media/Push_up_girl.jpg">
</div>
</div>
Css Code:
.cutCorner {
position:relative;
border:1px solid transparent; display: inline-block;
}
.cutCorner img {
display:block;
}
.cutCorner:after {
position:absolute; left:-2px; top:-2px; content:'';
border-bottom: 310px solid white;
border-left: 310px solid transparent;
}
https://jsfiddle.net/Harpreet_devgun/hgo62n6a/12/