I want to create a menu like notebook post-it papers. Seems like this:
Basically want to place two divs side by side and make left div a page, and right div a menu. And if the height of page increased, the space between two menu elements should be expand proportionally. I have been trying for 2 days and the code is like that:
<div class="specific_recipeBook_withStickers">
<div class="specific_recipeBook">
<div class="specific_recipeBook_spiral"></div>
<div class="specific_recipeBook_main">
<ul class="specific_recipeBook_list">
<li class="specific_recipeBook_list_unit">
<div class="specific_recipeBook_main_lines"></div>
<a class="specific_resipeBook_list_unit_text" ><h4 id="specific_resipeBook_list_unit_name">Kuru Fasulye</h4>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 u</a>
</li>
</ul>
</div>
</div>
<div class="specific_recipebook_stickers">
<div class="specific_recipeBook_sticker" id="recipeBook_stickers_1" ><a class="specific_recipeBook_stickers_text">Salata</a> </div>
<div class="specific_recipeBook_sticker" id="recipeBook_stickers_2" ><a class="specific_recipeBook_stickers_text">Tatlı</a></div>
<div class="specific_recipeBook_sticker" id="recipeBook_stickers_3" ><a class="specific_recipeBook_stickers_text">Yan Yemek </a></div>
<div class="specific_recipeBook_sticker" id="recipeBook_stickers_4" ><a class="specific_recipeBook_stickers_text">Anayemek </a></div>
</div>
</div>
JSFiddle
But it is not working well. What way should I use to do?
use something like this function
$(document).ready(function ($) {
$(".specific_recipeBook").each(function(j,d) {
var maxHeight = 0;
maxHeight = $(d).height();
var ratioedHeight = maxHeight*0.08;
console.log(maxHeight);
document.getElementById("recipeBook_stickers_1").style.marginBottom = 3+ ratioedHeight+"px";
document.getElementById("recipeBook_stickers_1").style.marginBottom = 3+ ratioedHeight+"px";
document.getElementById("recipeBook_stickers_2").style.marginBottom = 3+ ratioedHeight+"px";
document.getElementById("recipeBook_stickers_3").style.marginBottom = 3+ ratioedHeight+"px";
document.getElementById("recipeBook_stickers_4").style.marginBottom = 3+ ratioedHeight+"px";
});
});
Related
I'm new on programing and I'm studying HTML and CSS.
But today I have a issue that I can't figure how to solve:
I'm trying to add a background to a footer and it work pretty nice. But when I add "columns class" in some 'divs' it jusp stop works.
I'm adding two JS, first one whitout columns' class and a seccond one whit columns' class.
I know I'm doing something wrong, but I can't figure what.
First Code whit background working perfectly
Seccond Code whit background does't work
And I'm puting here my HTML code:
<footer>
<div class="footer">
<div class="container">
<div class="six columns">
<h3>Nossa História</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.</p>
</div>
<div class="three columns">
<h3>Contato</h3>
<ul>
<li>- 38 99999-9999</li>
<li>- contato#bikcraft.com</li>
<li>- Salinas - MG</li>
</ul>
</div>
<div class="three columns">
<h3>Redes Sociais</h3>
<ul>
<li><img src="img/facebook-icone.svg" alt="Ícone Facebook"></li>
<li><img src="img/instagram-icone.svg" alt="Ícone Instagram"></li>
<li><img src="img/youtube-icone.svg" alt="Ícone Youtube"></li>
</ul>
</div>
</div>
</div>
</footer>
And my CSS code:
.footer {
color: #fefefd;
background: #191f28;
}
This question already has an answer here:
Media query in responsive email template
(1 answer)
Closed 3 years ago.
I'm setting up an email which contains in the body a picture and some text. On normal computer screens the image is to the left and the the associated text to the right (using inline-block).
This looks like so:
(https://www.flickr.com/photos/183424995#N08/48518551371/in/dateposted-public/)
When the screen size is changed ie. for an i-phone, I'm aiming to get the text to move underneath the image and rather than just having a width of half the screen (as it's inline-block), to take up the whole width of the screen underneath.
What I'm trying to get:
https://www.flickr.com/photos/183424995#N08/48518549646/in/dateposted-public/
What is actually happening:
https://www.flickr.com/photos/183424995#N08/48518724692/in/dateposted-public/
I've created a "main" div containing the image div, and a div containing the text, both inline-block. The "main" div has a width set to 100% and the text div has a min and a max div so it can move from next to the image to under the image depending on screen width.
I've tried rejigging the max width of the text div to be wider, but then the text never remains to the side of the image. And I'm trying to avoid floating anything.
I can't use bootstrap or flexbox as it's an email so am limited to fairly basic CSS.
The JSFiddle is https://jsfiddle.net/cfn76vqz/ to show what kind of responsiveness I have so far. And the general HTML structure is as below.
<div id="main">
<div id="left">
<div >
<img src="https://via.placeholder.com/300x200/0000FF/FFFFF" />
</div>
</div>
<div id="right">
<div >
<span>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.</span>
</div>
</div>
</div>
TLDR: I'm stumped on how to make the text div essentially be 100% of the width if underneath the image but also 50% if there's space to have it to the side of the image. As far as I understand it's always going to be limited to 50% as it's part of an inline-block section.
Because you set width with this why it's not fully of width
max-width: 50%;
So... How we can do
We need to use FLEX display
like this
#main {
/*---HERE---*/
display: flex;
flex-wrap: wrap;
/*----------*/
background: yellow;
width: 100%;
}
#left {
background: orange;
}
#right {
/*---HERE---*/
flex-basis: 0;
flex-grow: 1;
min-width: 50%;
/*----------*/
background: green;
vertical-align: top;
}
<!-- YOUR OLD CODE -->
<div id="main">
<div id="left">
<div>
<img src="https://via.placeholder.com/300x200/0000FF/FFFFF" />
</div>
</div>
<div id="right">
<div>
<span>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.</span>
</div>
</div>
</div>
if you want to learn about flex ...more here
you can use viewport units like width: 100vw and height: 100vh for make it responsive depending upon height and width of display.click here
I am a newbie in terms of web design.
I have centered an image, put a button below it, and when I click this button, some text appears below the image. When I click the button again, the text goes up, and so we see the initial view: only the image and the button (similar to the effect here https://www.w3schools.com/bootstrap4/bootstrap_collapse.asp) .
<div class="container">
<h2>Simple Collapsible</h2>
<p>Click on the button to toggle between showing and hiding content.</p>
<button type="button" class="btn btn-primary" data-toggle="collapse" data-target="#demo">Simple collapsible</button>
<div id="demo" class="collapse">
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.
</div>
</div>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
Now, I don't want to make this text appear under the image, I want the image to move left and the text to appear on where the image was before when clicking that button, even a little bit more on the right, but still on the same line.
Can someone please help me doing this? Thank you!
Bootstrap doesn't have a pre-fab method to do what you want, and you cannot tweak the collapse method to do it.
However, what you want to do can be easily done within the Bootstrap grid system - just not with pre-fab Bootstrap tools.
Here's how that might look:
$('.btn').click(function(){
$('.imgDiv').animate({
width: '0px'
},1000, function(){
$('img').css('width','0px');
});
$('.txtDiv').animate({
width: '90vw',
marginLeft: '10vw'
},1000, function(){
$(this).removeClass('hidden');
});
});
.full-width {width:100vw;}
.imgDiv{min-height:110px;}
/* max-height required so zero-width does not auto-expand height */
.hidden{width:0px;max-height:100px;overflow:hidden;}
<div class="container">
<div class="row flex-nowrap">
<div class="imgDiv text-center full-width">
<img src="http://placekitten.com/100/100" />
</div><!-- .imgDiv -->
<div class="txtDiv hidden">
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.
</div><!-- .txtDiv -->
</div><!-- .row -->
<div class="row d-flex justify-content-center">
<button type="button" class="btn btn-primary">Show Text</button>
</div><!-- .row -->
</div><!-- .container -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
Because Bootstrap4 is built on flexbox (in fact, the entire Bootstrap grid was redesigned around flexbox in Bootstrap4) it is important to know some Bootstrap flexbox classes.
There is a reason why Bootstrap re-did their entire platform from Bootstrap3 to Bootstrap4, primarily to change from using floats to flexbox.
Flexbox requires two things:
A parent container (e.g. DIV, section, aside, p, etc)
One or more child elements (e.g. div, p, img, etc)
You turn flexbox on on the parent: display:flex;
Then, there are various switches. Some are set on the parent (as in the case of justify-content) but others might be set on the items (as with flex-grow:1)
YouTube tutorial - fast-paced and best-of-breed
Here is a great cheatsheet for Flexbox.
Watch the tutorial and in 40 mins from now your problem will be solved -- and you'll know flexbox.
P.S. I have no connection to the video or its presenter - I was fortunate to discover it, and now pass it along.
Between:
<h2>Menu</h2>
and
<h5>Hover to see more!</h5>
I have this huge gap, is there a way to remove it?
For more references this is my code before heading 2:
<div class="container">
<img src="Lato Font Test.png" alt="Avatar" class="image">
<div class="overlay">
<div class="text"><p>About Us // Origin</p><p>Sample Text</p><p>Sample Text</p><p>Sample Text</p></div>
</div>
</div>
<br></br>
And after heading 5:
<ul id="accordion">
<li>
<h2>MENU // SOUPS</h2>
<div class="content">
<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.</p>
</div>
</li>
Picture Reference: http://i.imgur.com/Imc3DPb.png
Thanks in advance!
One of your elements has a default padding or margin. You can inspect your elements with your browsers dev tools to figure out which if not both is causing the issue. Adjust your paddings and margins using padding: x; and margin: x; x being the amount of pixels [ex. 5px] you want.
Problem: http://i.snag.gy/TYvi4.jpg
Fiddle: http://jsfiddle.net/CadDC/7/
As you can see in the problem image above, I would like to position the image alongside the title but keeping the structure of the html for a responsive layout.
<div class="listingWrapper clearfix">
<div class="headlineText">FLOAT: RIGHT</div>
<div class="subText">FLOAT: RIGHT</div>
<div class="logo">FLOAT: LEFT (ALONGSIDE HEADLINE)</div>
<div class="introduction">FLOAT: RIGHT</div>
Look at this fiddle: http://jsfiddle.net/caprella/7kbVX/
I propose to add one more wrapper .heading for .headlineText and .subText. It will give us opportunity to move the whole header. But that .heading steel needs fixed width:(
Check the Js fiddle
http://jsfiddle.net/CadDC/9/
<div class="listingWrapper clearfix">
<div class="logo">
<img class="listingImage" src="http://media-cdn.tripadvisor.com/media/photo-s/02/d0/d7/ed/hotel-du-vin-york.jpg" />
</div>
<div class="headlineText"><h2>Hotel name</h2></div>
<div class="subText">Mars - 0.7 miles from Mars City Centre</div>
<div class="introduction">
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 nost
</div>
</div>
Cant you just:
.listingImage{
max-width: 190px;
float: left;
}
I think this is your perfect answer http://jsfiddle.net/CadDC/14/ .
If you want it to be responsive you must give width and all in %.