Wanting text to overflow into another div - html

Beginner CSS question here.
I have the home page of a website I'm working on set out perfectly. I have two `divs
#desktop-navbar {
text-transform: uppercase;
width: 100%;
height: 90px;
position: fixed;
z-index:1;
}
#desktop-nav-wrapper {
height: inherit;
padding: 0 45px;
}
#desktop-nav-wrapper nav ul {
float: right;
padding-top: 35px;
font-size: 16px;
}
#desktop-nav-wrapper nav li {
position: relative;
display: inline-block;
padding-left: 25px;
color: #000000;
font-family: Thasadith;
font-weight: 700;
}
#desktop-navbar #mobile-menu-link{
display: none;
}
#desktop-nav-wrapper nav li:hover {
font-weight: 900;
}
#desktop-nav-wrapper.solid {
transition: background-color 1s ease 0s;
background-color: #eeeeee;
}
#desktop-logo.solid-fonts {
transition: color 1s ease 0s;
background: linear-gradient(90deg, #000 100%, #000 0%) fixed;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
#desktop-nav-wrapper nav li.solid-fonts {
transition: color 1s ease 0s;
color: #000000;
}
#desktop-nav-wrapper {
font-weight: bold;
font-size: 18vw;
text-transform: uppercase;
color: black;
letter-spacing: 2px;
}
#home {
height: 700px;
position: relative;
}
#home-container {
height: inherit;
width: 100%;
display: flex;
position: absolute;
}
#home-colour-one {
height: inherit;
width: 33%;
background-color: #314455;
}
#home-colour-two {
height: inherit;
width: 67%;
background-color: #dddddd;
}
<div id="desktop-navbar">
<div id="desktop-nav-wrapper">
<nav>
<ul id = "desktop-nav-content">
<li class="desktop-items">Casa</li>
<li class="desktop-items">Sobre Mi</li>
<li class="desktop-items">Servicio</li>
<li class="desktop-items">GalerĂ­a</li>
<li class="desktop-items">Contacto</li>
<li id="mobile-menu-link"><a>Menu</a></li>
</ul>
</nav>
</div>
</div>
<div id="home">
<div id="home-container">
<div id="home-colour-one">
<h3>Bettoo Kaozink</h3>
</div>
<div id="home-colour-two" class="container">
</div>
</div>
</div>
side by side with different colours (I know I could use one div and use the CSS gradient method, but I want to add some sweet fade-in to both of these divs at a later point).
But I want to place the text on the halfway point between the two divs (so one half is in the blue and the other half is in the grey).
Right now, I only have the text in one div of the home page (home-colour-one), but I'd like it to be spread across the two. Is there a way I can get the text to overflow into the grey div (home-colour-two)? Or just have the text in a separate div and place on the point separating the two divs?
I also know I can have the H3 of Bettoo Kaozink in the nav bar, but that is something I want to avoid. As ideally, I would like Bettoo Kaozink centered vertically in the container.
Cheers

One way to approach this is by using flexbox by adding display: flex to the container. If you haven't learned about how flexbox works, I'd recommend you to read up on this article.
I've created a mini prototype here of what you wanted. There are two things you should do to the JSFiddle in advanced to help you understand the code a bit better:
On line 15 of the CSS code, change the flex-grow property to some other value.
Use JavaScript to center the text relative to the div-container
Once you understand flexbox, it opens a door to so many different options that you can choose from.
I hope that it works out for you. If not, just tell me in the comments.

Honestly the structure of your page, based on what I can understand from here, it's not so solid.
Anyway, just in this context, and if I get right your goal, so having your h3 (or whatever text container you will add then) floating between the two divs [id="home-colour-one" and id="home-colour-two"], and centered vertically, a solution would be adding this ad the end of your CSS:
/* ADD THIS!!!*/
#home-colour-one h3 {
position: absolute;
top:50%; left:16.5%;
transform: translateY(-50%);
}
Here a JS Bin: https://jsbin.com/ralicul/edit?html,css,output

Related

How to change a flexbox item margin's color on hover?

I'm trying to create a responsive navbar where each item gets its' background highlighted (color change to higher saturation) on hover. However, only the link text gets highlighted.
I'm using a flexbox container with evenly distribution, plus a logo with margin-right:auto so it stays fixed at the left side.
What I want is getting the whole space (as seen in the dev console
) highlighted on hover. After digging around, I believe that area highlighted using the dev-console is the margin, thus the question title.
I figured it out using padding but it looks sketchy, it jumps around so it's far from ideal.
Here's my code:
* {
margin: 0;
padding: 0;
}
.top-nav {
background-color: rgb(148, 174, 186);
height: 120px;
display: flex;
justify-content: space-evenly;
}
.logo {
height: 100px;
margin-right: auto;
}
.nav-links {
font-family: 'Montserrat';
font-style: bold;
text-align: center;
margin: auto;
font-size: 45px;
color: white;
text-decoration: wavy; //don't mind this, just how I managed to clear the links default styling
height: auto;
}
.nav-links:hover {
background: rgb(39, 136, 180);
color: black;
}
<div class="top-nav">
<a class="logo-link" href="index.html"><img class="logo" src=img/Logotipo.png> </img>
</a>
<a class="nav-links" href=m y-bio.html>MY BIO</a>
<a class="nav-links" href=e xperience.html>EXPERIENCE</a>
<a class="nav-links" href=projects.html>PROJECTS</a>
<a class="nav-links" href=hire-me.html>HIRE ME!</a>
</div>
I was thinking about making the links into divs but I'm afraid it will end up with the same result.
You can't add a background colour to a margin value, that isn't possible. If you want it to be in the links add the following to your .nav-links class:
.nav-links {
padding: 1rem;
transition: .2s;
}
If you want the menu items to fill the full height of the parent element with the same effect you can do:
.nav-links {
height: 100%;
display: flex;
align-items: center;
padding: 0 1rem;
transition: .2s;
}
I'm not quite sure I know what you wish to achieve though.

Web Design/CSS: Animated logo with CSS?

For a web project, I would like to create an animated logo in the top left corner of a website. The logo should animate when the visitor is hovering over it, i.e. when not hovering, the logo should display the abbreviated version of the website's name and on hovering it should animate into the fully spelt out version of the name. Here's a quick demo was done in After Effects which shows what I would like to achieve:
The only time I have ever seen something like this was on this website http://ourplace.studio/, the site of a design studio called 'Our Place', in the top left corner. The logo animated pretty much the same way when hovering over it. But looking into the website's source I could not figure out how it is done. The logo is inside a <div> with an <a> tag which has been assigned a class called animation-link. That is as far as I got.
<div id="logo" class="lma">
<a href="http://ourplace.studio" class="animaition-link">
<span>Our</span> <span>Place</span>
</a>
</div>
It would be fantastic if someone could help me to figure this out. It would be a good learning experience to understand how something like this is done.
You can achieve this using css3 transitions:
transition: width 1s;
I made a fiddle that solves your task: https://jsfiddle.net/jmxLrq4m/
Note that this won't work with dynamic width (width: auto) as the transition needs a fixed start- and end value to animate through. Therefor I gave each span a class and set fixed widths on default and on hovering.
The transition attribute combines all transition-properties, which you could also separate e. g.
transition: width;
transition-duration: 1s;
...
See here for more information about transitions: https://www.w3schools.com/css/css3_transitions.asp
i have made a fiddle for you, i hope that works for you
<div id="logo" class="lma">
<a href="http://ourplace.studio" class="animsition-link">
<span>O<i>ur </i></span><span>P<i>lace</i></span>
</a>
</div>
div#logo a {
font-size: 40px;
color: #333;
text-decoration: none;
}
div#logo span {
transition: all .3s;
overflow: hidden;
display: inline-block;
float: left;
}
div#logo i{
font-style: normal;
max-width: 0;
overflow: hidden;
display: inline-block;
vertical-align: bottom;
transition: all 1s;
}
div#logo:hover i {
max-width: 200px;
}
Hi please check this demo here
https://jsfiddle.net/JentiDabhi/83auj9v8/
HTML:
<div id="logo">
<a href="#" class="animsition-link">
<span>Demo</span><span>Logo</span>
</a>
</div>
CSS:
#logo {
width:210px;
font-size: 40px;
}
#logo span {
display: inline-block;
float: left;
margin-right: 0;
overflow: hidden;
}
#logo span {
transition: all 1s ease 0s;
}
#logo span:nth-child(1) {
padding-top: 1px;
width: 28px;
}
#logo span:nth-child(2) {
padding-top: 1px;
width: 22px;
}
#logo:hover span:nth-child(1), .hmslider-visible #logo span:nth-child(1) {
padding-top: 1px;
width: 100px;
}
#logo:hover span:nth-child(2), .hmslider-visible #logo span:nth-child(2) {
padding-top: 1px;
width: 100px;
}

How to make Twitter-Bootstrap like buttons

I basically want to create a button like the big "Download Bootstrap" button on this side: http://getbootstrap.com/
Note: I want to create the button myself just with css & html and not with the twitter-bootstrap framework
I was able to do it pretty well but then I noticed that there was a bug: http://jsfiddle.net/vk5DV/
If you zoom in while hovering over the button you will notice that in the corner of the button there is something wrong. I think the link itself gets styled with the white background but I have no idea why.
#googlink a {
color: white;
transition: all 0.2s linear 0s;
}
#googlink :hover {
background-color: white !important;
color: #99CC00;
}
why does the link get a white background too (and not only the button div)?
If a border-radius is added it seems ok
eg
#googlink :hover {
background-color: white !important;
border-radius: 6px;
color: #99CC00;
}
http://jsfiddle.net/f3kzb/show/
Although if you simplify it a bit, i think it works fine with the code you already have. Also specified as a class to be used with any link.
http://jsfiddle.net/fe25t/
html
<div id="green">
Google
</div>
css
body {
margin: 0;
padding: 0;
}
#green {
background-color: #99CC00;
}
a {
text-decoration: none;
color: black;
}
.special-link {
border-radius: 10px;
margin: 40px;
display: inline-flex;
height: auto;
width: auto;
font-size: 65px;
background-color: #99CC00;
border: 2px solid white;
color: white;
transition: all 0.2s linear 0s;
}
.special-link:hover {
background-color: white !important;
color: #99CC00;
}
Do not use a div, just style the link (a).
Currently you are styling both the link and the div, which is not necessary - this creates conflicts and, semantically, is useless.
You would want to use a div only if you needed to nest multiple elements within it and then position the div to position all the elements at once (just an example).
There you go.. check this out.. The hover border has to be round so that it does not overlap the normal border. This addition is under the hood of the main button border so it does not pop out at the corners.
#googlink :hover {
border-radius: 6px;
background-color: white !important;
color: #99CC00;
}
http://jsfiddle.net/47vDq/

Opacity messing up text

So I'm having an issue. I have a header, and text on the header. The headers opacity is 0.55 and the text is wrapped inside of the header class. Now here's the issue, since its inside, the text also gets the opacity applied to it. Here's what it looks like . As you can see the text is kind of light. I've tried applying the opacity to 1.0 on the ui li sector itself, but that hasn't helped either. I've also tried the z-index, and that still hasn't helped.
Here's my HTML
<div class="header">
<ul>
<li>
Email
</li>
<li>
Github
</li>
<li>
Twitter
</li>
</ul>
</div>
And the CSS
.header{
text-align: center;
height: 55px;
width: 100%;
background: #EFEFEF;
opacity: 0.55;
position: fixed;
}
ul li{
display: inline-block;
color: #000;
opacity: 1.0;
font-size: 28px;
font-family: 'Avenir Next';
padding: 10px 35px;
}
And lets not forget the demo. Any ideas?
Instead of using opacity on the header, set the background color to rgba(239,239,239, 0.55) and get rid of the opacity property all together
You can either use #Erik's solution (which is cleaner), or you can also add a separate element behind it: (DEMO)
<div class="header headerbg"></div>
<div class="header">...etc...</div>
CSS:
.headerbg{
background: #EFEFEF;
opacity: 0.55;
}
.header{
text-align: center;
height: 55px;
width: 100%;
position: fixed;
}
This might also be achievable using the :before pseudo-element, to keep the display a bit more separated.

Building overlapping, oddly-rotated sprites

My current project involves setting up a bunch of sidebar links, such that the finished design looks like this:
The envelopes are supposed to move and overlap (i.e., change z-index), depending upon which icon/text is currently has :hover state.
I thought each would be a separate PNG file, but I've been given a sprite that looks like this:
Any suggestions how I could achieve this? Normally I'd just change the background position of the list elements each piece of text is in, but I don't think this is possible given the overlapping nature of these. Does he just need to export it differently?
Many thanks...
To me it looks like that sprite would work perfectly. The left most image is for when book is hovered, second image for twitter, third for facebook, forth for email. I'm guessing the last one is just the default state. Its tricky to make this work with pure css and :hover (but possible!), however, it would be extremely easy with javascript.
For the pure css solution, the div with the sprite would have to be the child of all the text elements, so you could change the background based on :hover on the parent (the text). If this isn't clear, I can make you some example code.
Edit:
Its not perfect, but its a proof of concept.
JsFiddle: http://jsfiddle.net/jp6fy/
CSS:
#side{
position:relitive;
height:341px;
width:250px;
}
#link1{
top:0;
}
.link{
position:absolute;
left:0;
top:85px;
height:85px;
padding-left:160px;
width:90px;
}
#image{
position:absolute;
top:-255px;
left:0;
z-index:-1;
background:url(http://i.stack.imgur.com/I2Y4k.png) -720px 0;
height:341px;
width:150px;
}
#link1:hover #image{
background-position:-540px 0;
}
#link2:hover #image{
background-position:-360px 0;
}
#link3:hover #image{
background-position:-180px 0;
}
#link4:hover #image{
background-position:-0px 0;
}
HTML:
<div id='side'>
<div class='link' id='link1'>
email
<div class='link' id='link2'>
facebook
<div class='link' id='link3'>
twitter
<div class='link' id='link4'>
book
<div id='image'></div>
</div>
</div>
</div>
</div>
</div>
It is possible. (But ugly.)
As a :hover selector can only affect elements inside (or directly adjacent) to the triggering element, the solution is to nest the trigger elements: (jsFiddle)
<style>
div {
width: 100px;
height: 100px;
position: absolute;
left: 100px;
}
#image { background: black; }
#trigger1, #trigger1:hover #image { background: red; }
#trigger2, #trigger2:hover #image { background: green; }
#trigger3, #trigger3:hover #image { background: blue; }
</style>
<div id="trigger1">
<div id="trigger2">
<div id="trigger3">
<div id="image"></div>
</div>
</div>
</div>
But preferably, you'd get the envelope sprites exported separately (you can of course still use CSS sprites). That should give you simpler HTML and CSS, a smaller image, and you'll avoid having to muck around with nested absolutely positioned elements, each having its own coordinate system.
I tried an approach which keeps the markup fairly simple, with only one extra non-semantic div per item:
<ul>
<li id="email">
<div class="background"></div>
<em>Email</em> chris
</li>
<li id="facebook">
<div class="background"></div>
<em>Facebook</em> follow us
</li>
<li id="twitter">
<div class="background"></div>
<em>Twitter</em> your life away
</li>
<li id="book">
<div class="background">
</div><em>Book</em> a project
</li>
</ul>
I positioned all the different copies of the background div at the same place, then varied the background position based on the hover states:
/* First, just style the document and the list text in general.
skip on for the important bit */
body {
background-color: black;
color: white;
}
ul {
width: 350px;
margin-top: 40px;
position: relative;
}
li {
margin-right: 40px;
font-family: "Century Gothic", Helvetica, sans-serif;
text-align: right;
margin-bottom: 0px;
padding: 15px 4px 25px 0;
}
li em {
text-transform: uppercase;
display: block;
}
li:hover {
color: red;
}
/* From here down is the important bit */
/* Set up the sprite in all the .background divs */
div.background {
background-image: url(http://i.stack.imgur.com/I2Y4k.png);
position: absolute;
top: 0;
left: 0;
height: 341px;
width: 160px;
}
/* By default, turn off the background in all the divs */
div.background {
display: none;
}
/* Just picking an arbitrary item to show the default, non-hover background */
#email div.background {
display: block;
background-position-x: -737px;
}
/* If we're hovering over the list as a whole, disable the default background,
so it doesn't show up underneath the background we want to display */
ul:hover #email div.background {
display: none;
}
/* For the email item, which shows our arbitrary default background, override
to the email background on hover with more specificity than the default rule */
ul:hover #email:hover div.background {
display: block;
background-position-x: 0px;
}
/* For all other items, override to their background on hover */
#facebook:hover div.background {
display: block;
background-position-x: -375px;
}
#twitter:hover div.background {
display: block;
background-position-x: -189px;
}
#book:hover div.background {
display: block;
background-position-x: -556px;
}
Working, though slightly rough example, in this jsFiddle.
Note that it's okay to have multiple copies of the sprite in multiple different divs; the browser will just grab one copy for its cache and use that for all instances of the image.
Could you create an image map and then hover swaps the image to the one with the correct envelope in front. See this link on an interesting link
google search link on idea
My method with clean HTML.
.nav { position: relative; }
.nav li {
margin-left: 179.8px;
list-style-type: none;
}
.nav li:before {
position: absolute;
left: 0; top: 0;
content: url(http://i.stack.imgur.com/I2Y4k.png);
clip: rect(0 899px 341px 719.2px);
margin-left: -719.2px;
z-index: 1;
}
.nav li:hover:before { z-index: 2; }
.email:hover:before {
clip: rect(0 179.8px 341px 0);
margin-left: 0;
}
.facebook:hover:before {
clip: rect(0 359.6px 341px 179.8px);
margin-left: -179.8px;
}
.twitter:hover:before {
clip: rect(0 539.4px 341px 359.6px);
margin-left: -359.6px;
}
.book:hover:before {
clip: rect(0 719.2px 341px 539.4px);
margin-left: -539.4px;
}
<ul class="nav">
<li class="email">Email</li>
<li class="facebook">Facebook</li>
<li class="twitter">Twitter</li>
<li class="book">Book</li>
</ul>