I have a menu icon which is displayed when window reaches certain size.
Everything is fine but the position of this icon. I don't know how to get this to the right side of the site - the most favourable would be to define the right property.
Here's what it look like now:
And I would like it to be really close to the right boundary of the window.
Here's the code:
HTML:
<div class="header">
<div class="row">
<div class="col-sm-offset-1">
<img src="images/logo.svg">
</div>
<div class="col-xs-offset-1">
<div class="iconcont">
<a href="javascript:void(0);" class="icon" onclick="header()" >
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
</a>
</div>
<div class="menu" id="mainmenu">
Home
News
Members
History
Projects
</div>
</div>
</div>
</div>
CSS:
/* HEADER */
.header {
background-image: url("images/stars.png");
width: 100%;
height: 150px;
}
header img {
height: 100%;
width: 100%;
}
/* MENU */
.menu {
background-color: transparent;
overflow: hidden;
}
.icon {
display: none;
}
#media screen and (max-width: 1370px) {
.menu a {
display: none;
}
.icon {
display: block;
}
}
.iconcont {
top: 55px;
position: relative;
}
I tried to wrap it in div (iconcont) but the right or left property doesn't work as I want. I guess it's because the whole menu is "col-xs-offset-1" (Flexbox Grid) but I don't know how to fix this and not ruin everything else.
EDIT:
For anyonewondering I fixed it. I put the icon in another div col-offset-5 but AFTER menu. I don't know why I hadn't done it in the first place.
Maybe add an ID to the class you want special treatment for and then make an exception with that?
HTML
<div class="col-xs-offset-1" id="header-layout">
<div class="iconcont">
<a href="javascript:void(0);" class="icon" onclick="header()" >
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
</a>
</div>
<div class="menu" id="mainmenu">
Home
News
Members
History
Projects
</div>
</div>
CSS
#media screen and (max-width: 1370px) {
#header-layout
{ display: flex;
align-items: flex-end;
}
}
Related
I'm working on making an e-commerce website. For the footer, I want to place the e-commerce's brand name on the top left, and the social media icon links on the top right.
The layout I want as follows:
However, the footer currently looks like this:
Here is what I have coded.
.footer-top {
display: inline-block;
width: 100%;
}
.title {
float: left;
}
.social {
float: right;
}
<div class="footer-top">
<div class="name">
<h1><span class="bigger">XXXX</span></h1>
</div>
<div class="social">
<!--Social media icons-->
</div>
</div>
What is my error?
You can use display:flex; to style navbar. Copy these code and paste in your CSS instead of code you have provided.
.footer-top {
display:flex;
justify-content:space-between;
align-items:center;
}
<div class="footer-top">
<div class="name">
<h1><span class="bigger">XXXX</span></h1>
</div>
<div class="social">
<!--Social media icons-->
fb
insta
</div>
</div>
The reason why your layout wasn't what you expected is because you had .name in html but .title in css. Correct the class name and floats will work as well. Also there is no need to have display: inline-block and width: 100%. <div> is a block by default and occupies 100% of width.
That being said, with flex it is easier to align content vertically.
.title {
float: left;
}
.social {
float: right;
}
<div class="footer-top">
<div class="title">
<h1><span class="bigger">XXXX</span></h1>
</div>
<div class="social">
<!--Social media icons-->
icon
icon
</div>
</div>
I have a button inside the header menu , That header contains the logo & social media icons & that button.
I want to make that button fixed , So that when I scroll it's always at the top of the screen.
Let's say I have the following html code:
.menu{background:#ddd}
.logo,
.social-media,
.sticky-container{
display:inline-block;
width:30%
}
.logo{background:#000}
.social-media{background:#080}
.sticky-container{background:#333}
.logo,
.sticky-container{color:#fff}
<div class="main_container">
<div class="wrapper">
<div class="menu">
<div class="logo">Logo</div>
<div class="social-media">
<div class="facebook">Facebook</div>
<div class="youtube">Youtube</div>
<div class="twitter">Twitter</div>
</div>
<div class="sticky-container">
<a class="sticky-element">Button</a>
</div>
</div>
</div>
</div>
I want the button with class sticky-element that is inside sticky-container to be sticky.
Set position: fixed; for your sticky-container class.
Here's the jsfiddle: https://jsfiddle.net/30shhy3L/2/
Edit:
From comments, as you have mentioned your real site at https://logosperformance.com, just change the css of [data-css="tve-u-163a8211f58"] element as following:
[data-css="tve-u-163a8211f58"] {
float: right;
z-index: 3;
position: fixed;
margin-top: -2px !important;
margin-bottom: 0px !important;
}
I have problem with overflow in on my website. When mouse is not over the left menu, it look OK, but when I move mouse over the menu and :hover is active, content (menu is a content) is a little smaller. I don't want this effect when :hover is active, menu is a little smaller.
Effect that I want is like on Youtube. If you are logged into your account, and if you pressed menu icon next to Youtube logo, you will get scroll menu. When mouse is not over the menu, nothing happens. But when you move your mouse over the menu, overflow is visible and this not change content size.
In brief:
I have this:
when overflow is active, content is smaller
What I want is this:
when overflow is active, content is NOT smaller
How can I do it ?
Thanks :)
My understanding, though it maybe flawed is that you have to already have the space that the scroll bar will populate there. You didn't give us any code so I had to fabricate it, but this is what I came up with
https://jsfiddle.net/link2twenty/bxz60j4r/
HTML:
<div class="sidebar">
<div class="container">
<div class="profile">
<img src="http://moss-side.yoursquaremile.co.uk/img/default-profile-pic.png" />
</div>
<div class="card">
<img src="https://cdn4.iconfinder.com/data/icons/ionicons/512/icon-person-128.png" />
<span>Test card data</span>
</div>
<div class="spacer">
<hr>
</div>
<div class="card">
<img src="https://cdn4.iconfinder.com/data/icons/ionicons/512/icon-person-128.png" />
<span>Test card data</span>
</div>
<hr>
<div class="card">
<img src="https://cdn4.iconfinder.com/data/icons/ionicons/512/icon-person-128.png" />
<span>Test card data</span>
</div>
<hr>
<div class="card">
<img src="https://cdn4.iconfinder.com/data/icons/ionicons/512/icon-person-128.png" />
<span>Test card data</span>
</div>
<hr>
<div class="card">
<img src="https://cdn4.iconfinder.com/data/icons/ionicons/512/icon-person-128.png" />
<span>Test card data</span>
</div>
</div>
</div>
CSS:
.sidebar {
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: 400px;
overflow: hidden;
padding-right: 17px;
}
.sidebar:hover {
padding-right: 20px;
overflow-y: auto;
}
.sidebar .container {
width: 400px;
background: #8cc34b;
margin-bottom: -25px;
}
.card {
opacity: .7;
width: 100%;
height: 120px;
background: #8cc34b;
}
.card span {
position: relative;
float: right;
padding-right: 50px;
top: 50%;
}
hr {
margin-left: 120px;
margin-right: 20px;
border-color: darkgreen;
opacity: .7;
}
You can try the following:
.scrollable {
border: 1px solid black;
width: 100px; /* specify the width you like here */
overfow: hidden;
}
.scrollable:hover {
overfow-y: scroll;
}
nav {
border: 1px solid grey;
width: 80px; /* specify the width which is calculated as widthOfScrollable - widthOfScrollbar */
}
.item1, .item2 {
height: 10px;
width: 100%;
}
.item1 { background: red }
.item2 { background: blue }
<div class="scrollable">
<nav>
<li class="item1"></li>
<li class="item2"></li>
</nav>
</div>
Borders and colors are used to show the blocks.
Here you preserve some space for the scrollbar on the right side. Problem here is to preserve exactly the scrollbar size for the current user / browser / OS. They all could have differences in scrollbar width value, so there are two ways for you to go:
Use this function from here Getting scroll bar width using JavaScript to calculate the proper size of the scrollbar
Make the scrollbar margin big enough to cover any case on any operating system
I'm trying to make an booking box with an white background over an image on my front page. So far I have managed to put an box on top with the following code:
Code:
<div class="row">
<div class="col-sm-12 contentpage">
<div class="frontimage">
<img src="~/images/index.jpg" />
<div class="col-sm-4">
<div class="bookingbox">
</div>
</div>
</div>
</div>
</div>
Css:
.bookingbox {
background-color: white;
position: absolute;
height: 100px;
margin-top: -580px;
margin-left: 10px;
}
#media (min-width: 1200px) {
.bookingbox {
display: none;
}
}
The problem now is that when you going from, lets say 1600px to 1200px the white box moves, can't make it to be static inside the image.
All my images are set with the following css the they become responsive:
img {
max-width: 100%;
}
What should I change? any ideer?
Update:
The box fitting perfectly now.. but now the image is off the aligniment with the rest of the page.
Left side is good, but right side has become bigger somehow?
The answer here, you should use z-index to do this.
.bookingbox {
background-color: red;
position: absolute;
height: 100px;
width: 100px;
z-index: 2;
position: absolute;
top: 0;
}
.frontimage {
z-index: 1;
position: absolute;
}
#media (min-width: 1200px) {
.bookingbox {
display: none;
}
}
<div class="row">
<div class="col-sm-12 contentpage">
<div class="frontimage">
<img src="https://www.wonderplugin.com/wp-content/plugins/wonderplugin-lightbox/images/demo-image0.jpg" />
<div class="col-sm-4">
<div class="bookingbox">
</div>
</div>
</div>
</div>
</div>
Basically there are two images that are supposed to be on the center of the page and when the page is made smaller those images need to stack vertically. Currently I can get them to scale vertically, but I don't know how to center them. If I use margins or padding they stay in their position when the page is shrunk and don't look very good. I need them to move towards the edge as the page is being shrunk and then stack once the width of the page is too small. I'm doing this so they display properly on mobile and smaller resolutions. Does anyone know the best way to do this?
Here is the html:
<body>
<div class="wrapper">
<div class="wordmark">
<a href="#">
<img src="........." />
</a>
</div>
</div>
<div class="logowrap">
<div class="row">
<ul class="thumbnails">
<div class="logo1">
<li class="span6 home-left">
<a href="#">
<img src="SDI-logo.png" alt="SDI-logo" />
</a>
</li>
</div>
<div class="logo2">
<li class="span6 home-right">
<a href="#">
<img src="Debate-Logo.png" alt="SDI-logo" />
</a>
</li>
</div>
</ul>
</div>
</div>
</body>
Here is the CSS:
.navbar {
background-color:#000;
}
.container{
background-color:transparent;
}
.wrapper {
background-color:#000;
}
.wordmark{
max-width:100%;
max-height:100%;
padding-left:15px;
}
.logo1{
float:left;
.logo2 {
float:inherit;
}
.logowrap{
}
I have changed your code a bit. Take a look here and see if that helps you (http://jsbin.com/UdODawI/1/)
.thumbnails {
width: 100%;
margin: 0 auto;
list-style-type: none;
}
.wrapper {
background-color:#000;
}
.logowrap {
margin: 0 auto;
text-align: center;
}
.logo1{
display: inline-block;
}
.logo2 {
display: inline-block;
}
try adding this css to your image
.thumbnails img {
max-width:100%;
height: auto;
}
this allows your images to resize according to its parent