I am completely blocked on this problem, I am working with a CMS, and I am generating the articles, and I want them to be in two colums, so
here is the html code ( I deleted a bit of the php parts not to confuse you ):
<div id="contenu_col">
<?php
echo '<div class="col1">
<img src="square/'.$IMGACSQ.'" ><br/>
<p>'.aff($DATE).'<br/>'.aff($nom_projet).' - '.aff($ARTISTE).'</p></div>';
</div>
that generate an html code that look like that :
<div class="col1">
<a href="exhibition.php?ID=109">
<img src="square/E_3094_x.jpg" >
</a><br/>
<p>11.12. - 29.01.11.<br/>New impressions - New works - new artists - new space 5 and a happy new year)</p>
</div>
<div class="col1">
<a href="exhibition.php?ID=108">
<img src="square/BG_IoanGrosu06_x.jpg" >
</a><br/>
<p>30.10. - 04.12.10.<br/>Come here tomorrow - Ioan Grosu</p></div>
and the css :
.col1{
width:300px;
float:left;
padding: 3%;
display: block;
}
.col1 img{
width:100%;
}
.col1:after{
clear: both;
}
#contenu_col {
width:850px;
top:150px;
z-index:50;
left:460px;
position:absolute;
padding-bottom: 20px;
}
#contenu_col img{
width:100%;
}
( because I can't post images...)
It works 70% of the website; then sometimes some weird gap appears....
I don't understand what I'm doing wrong :(
RESOLVED.THANK YOU!!
Edit your col1 class and add a height,for example height:300px;
.col1 {
width: 300px;
float: left;
padding: 3%;
display: block;
height: 300px;
}
Also your DIV#encar isn't well styled.
it appears because .col1 height is not unified, try to add this to your css
.col1{
height: some value
}
Related
Im trying to do that: get 3 consecutives rows of a grid being "fixed;" but Im having problems that idk. Heres my code:
.main-container {
display:grid;
background-color:#e0e0e0;
grid-template-columns: 50% 50%;
box-sizing:border-box;
z-index:-1;
}
.main-container > * {
text-align:center;
display:flex;
justify-content:center;
align-items:center;
}
.main-container div {
color:black;
border: px solid black;
}
.main-container video {
display:block;
width:100%;
height:100%;
/* Scale video to container size */
object-fit: cover;
object-position: center;
z-index:10000;
}
.main-container h4 {
color:#edbd87;
}
.item1{
grid-column: 1 / 3;
background-color: green;
height:1080px;
}
.item2{
right:0;
left:0;
top:300px;
bottom:0;
position:absolute;
grid-column: 1 / 3;
display:inline-block;
z-index:1000000;
}
.item3{
background:#e0e0e0;
grid-column: 1 / 3;
height:40vh;
border-bottom:1px solid black;
}
.item4 {
padding:30px;
z-index:10;
width:100%;
height:800px;
}
.item4 img{
padding:15px;
justify-self:center;
display:block;
width:90%;
height:80%;
/* Scale video to container size */
object-fit: cover;
object-position: center;
border-radius: 80px 20px;
z-index:10;
}
.item5{
padding:40px;
width:100%;
display: inline;
z-index:9;
}
.item5 *{
padding:20px;
font-weight:bold;
font-size: 300%;
}
.item5 p{
margin-top:30px;
padding:40px;
font-weight:bold;
font-size: 180%;
}
.item5 h4{
margin-top:40px;
font-weight:bold;
font-size: 640%;
}
<?php get_header(); ?>
<div class="main-container">
<div class="item1">
<video id="vid" src="http://localhost/wordpress/wp-content/themes/twentytwentyone-child/img/coffee1.mp4" width="1920" height="1080" autoplay loop muted type="video/mp4"> </video>
</div>
<div class="item2">
<p style="font-size:50px; color:white;"> Join Us! </P>
<button type="button" class="btn btn-outline-warning" style="font-family:forum; font-weight:bold; background-color:transparent; border-radius: 3px; color:yellow; font-size:50px; border: 2px solid yellow;">Warning</button>
</div>
<div class="item3">
<img src="http://localhost/wordpress/wp-content/themes/twentytwentyone-child/img/logo.png" />
</div>
<div class="item4">
<img src="http://localhost/wordpress/wp-content/themes/twentytwentyone-child/img/arvan2.jpg" />
</div>
<div class="item5">
<h4>WHO WE ARE?</h4>
<p>
ArvanJobs is above all peace of mind. It is a new way
of working, of traveling, of training, of advancing in
your career. Whether you are a company looking for
workers or you are looking for a new job
opportunity, ArvanJobs will always be by your side,
selecting the best workers and the best companies
that will boost your career.
</p>
</div>
<div class="item6">
<h4>WHY WORK WITH US?</h4>
<p>
For our personal treatment, our advice, and above
all for our experience working in hotels in
numerous countries.
Because we know how difficult it is to take that step
of daring to work in a foreign country. Because we
know how hard it is to find the right staff.
</p>
</div>
<div class="item7">
<img src="http://localhost/wordpress/wp-content/themes/twentytwentyone-child/img/arvan4.jpg">
</div>
<div class="item8">
<h4>HOW WE WORK?</h4>
<p>
All candidates are interviewed by staff who have
worked in hotels, not offices
The same happens with our clients who have to
satisfy a series of criteria and guarantees for the
worker to work with us.</p>
</div>
<div class="item9">9</div>
<div class="item10">10</div>
</div>
<?php get_footer(); ?>
I want to fix .item4 and .item5 (they are in a row with 2 columns) and triplicate the row to be the same (with diff content) 3 times. And I want all of the 3 rows being fix.
The problem is when i put the position fixed in any of the .items the thing goes crazy.
I upload a image to clarify myself, sry about:
There u can see the 3 rows, I want the 3 rows being fixed, or at least the images being fixed for when I scroll down, the 2nd row will cover the 1st, and then the 3rd will cover the 2nd. I like this "diapositive" effect.
I tried some solutions, you can use this one:
when I position the element in the grid to fix, I make a new empty element with the same width and height, and the problem is solved.
I'm trying to create a mini-message board. I am using divs for each of the messages but I want to organise the divs in a grid. The grid should be flexible and responsive meaning that the number of columns and rows should dynamically change as the screen size does.
This is what I have done so far but it does not seem to work:
<div class="grid-container">
<?php
while($row = $result->fetch_assoc() ){
display($row['name'],$row['date'],$row['message']);
}
}
function display($name, $date, $message){
echo '<div class="flip-card grid-item">
<div class="flip-card-inner">
<div class="flip-card-front">
<p class="message">'.$message.'</p>
</div>
<div class="flip-card-back">
<h1 class="nameTitle"> '.$name.'</h1>
<p class="dateTitle">'.$date.'</p>
</div>
</div>
</div>';
}
?>
</div>
I know that the code for the displaying the information from the database works because the divs do appear. It's just they don't appear in a grid.
Thanks in advance for help!
I would recommend you FlexBox.
.body{
height: 100vh;
}
.column-wrapper {
height: inherit;
display: flex;
flex-flow: row wrap;
justify-content: space-around;
}
.column {
background: tomato;
padding: 5px;
width: 200px;
height: 150px;
margin-top: 10px;
line-height: 150px;
color: white;
font-weight: bold;
font-size: 3em;
text-align: center;
}
</style>
A simple example here: https://jsfiddle.net/04yxfwLg/1/
The trick is using justify-content to space-around
More on flexbox can be found on this amazing article.
I'm trying to build a page with a footer. It looks fine in 1600x900, but as soon as I scale down the footer moves to dead center and won't budge. Any suggestions would be appreciated
#Container{
width: 100%;
height: 100%;
position: absolute;
}
#Banner_Container {
position:relative;
width: 100%;
padding-bottom: 0.2%;
}
#Banner {
color: #FF7538;
font-style: oblique;
font-family: Courier New;
line-height: 1;
float: left;
}
#Index {
width: 80%;
background: rgba(250, 250, 250, 0.9);
border: 10px solid #ED9121;
border-style: outset;
padding-top: 2%;
float:left;
padding-bottom: 2%;
position: absolute;
margin-top: 30%;
min-width: 10%;
max-width: 80%;
}
#nav {
position: absolute;
margin: 0;
font-family: 'Roboto Condensed';
width: 15%;
float: right;
border: 5px solid #ED9121;
border-style: inset;
margin-top: 35%;
margin-left: 82%;
min-width: 5%;
max-width: 20%;
}
#footer{
width: 100%;
height: 50px;
position: absolute;
margin-top: 110%;
}
I was requested to do this in PHP
index.php
<?php
echo "<div id='Container'>";
include("banner.php");
include("navbar.php");
include("intro.php");
include("footer.php");
echo"</div>";
?>
So I have it separated like this
intro.php
<?php
echo "<div id='Index'>
<div id='Info'>
<img align='left' src='images/stock1.jpg'/>
<h2 align='left'>Welcome to East End Dental</h2>
<p>Ipsum</p><br><br><br><br><br><br><br><br><br><br>
<img align='right' src='images/stock2.jpg'/><br>
<h2 align='left'>Quality Guarantee</h2>
<p>Ipsum</p><br><br><br><br><br><br><br><br><br><br><br><br>
<div id='summary1'>
<center><h2>Our Dental Services</h2>
<img src='images/stock3.jpg'/></center>
<p>Ipsum<br><br></p>
</div>
<div id='summary2'>
<center><h2>Meet the Staff</h2>
<a href='staff.php'><img src='images/stock4.jpg'/></a </center>
<p>Ipsum.</p>
</div>
<div id='summary1'>
<center><h2>Contact Us Today</h2>
<img src='images/stock5.jpg'/></center>
<p>Ipsum</p><br><br>
</div>
</div>
</div>";
?>
footer.php
<?php
echo" <div id='footer'>
<center>
<p>Company Name 2016<br/>
Designed by <a href='mailto:email#gmail.com'>Name</a></p>
<a href='index.php'>Home</a> | <a href='services.php'>Services</a> | <a href='cerec.php'>CEREC®</a> | <a href='staff.php'>Staff</a> | <a href='contact.php'>Contact</a>
</center>
</div>";
?>
The problem is that you have the footer's margin-top set to 110% which will cause the footer to move around at different screen sizes. Percentage-based values are relative and change depending upon the parent container. I made a JSFiddle to show what this looks like with your code. The problem is faithfully reproducible by resizing the web browser.
To begin to fix this change your footer CSS. If you wanted a sticky/persistent footer that should would look something like this:
#footer{
width: 100%;
height: 50px;
position: absolute;
bottom: -50px;
}
I made a JSFiddle showing the solution so you can see this in action. This should address the footer floating to another location when the browser window resizes or is shown on a different device.
If you want the footer to just be at the bottom of the page and not stick there you would make this modification to the CSS:
#footer{
width: 100%;
height: 50px;
display: block;
clear: both;
}
This will just make sure the footer stays at the bottom of the content within the page and doesn't appear on the side of the previous element. Since you didn't specify if you were going for a stick footer I'm putting this in just to cover this other scenario.
In any case, hopefully this is the info you need to move forward on your website.
I am by far not an expert with PHP, and could really use some help creating my logo below into a H1. This is in my body section of the site:
<!--logo-->
<div class="logo" style="float:left;">
<?php echo $html->link($html->image('rental_logo.png'),array('controller'=>'homes','action'=>'index'),array('escape'=>false)); ?>
</div>
<div class="logo" style="float: right; margin-right: 470px; padding-top: 40px;">
Here is what I tried to create the above logo into a H1 tag:
<h1>
<a href="<?php echo $html->link($html->image('rental_logonew.png')?>" title="http://example.net/img/rental_logo.png"><br/>
<img src="<?php (http://example.net/img/rental_logonew.png);>/images/rental_logo.png" alt="vacation rentals" title="logo"
</h1>
I am very inexperienced writing code. So, I know the above that I tried to enter is wrong. Should I also be altering my look.css file?
/* css */
#logo {
background: transparent url("http://example.net/img/rental_logo.png") no-repeat scroll 0% 0%;
float: left;
/*width: 200px;*/
padding-bottom:10px;
text-indent: -3333px;
border: 0;
margin: 0;
}
#logo a {
display: block;
width: 280px; /* larger than actual image? */
height: 120px;
text-decoration: none;
border: 0;
}
I am attempting to add "rendered html" as requested. This may be incorrect, because I am unfamiliar with rendered html. I obtained the above codes from my header.ctp and look.css files.
($html->image('rental_logonew.png'),array('controller'=>'homes','action'=>'index'),array('escape'=>false)); ?>
Thanks for looking, and helping if you can.
In the php code i dont see where you close the "a" tag, just follow the structure bellow. I hope it will work.
CSS:
#logo {
width: 344px;
height: 82px;
margin-top: 10px;
/*float: left;*/
background: url(../images/logo.png) no-repeat;
}
h1.logo {
width:344px;
height:82px;
margin:0;
padding:0;
}
h1.logo a {
display: block;
height: 82px;
text-indent: -3000em;
overflow: hidden;
}
HTML:
<div id="logo"><h1 class="logo" title="logo"><a title="logo" href="/">Logo</a></h1></div>
Demo here..
Wanted to know if it is possible to get the same type of design layout as pinterest or jQuery masonry using only the new flexbox layout. Here is as far as I got it:
.flex-container {
display: -webkit-flex;
display: flex;
-webkit-flex-flow: row wrap;
flex-flow: row wrap;
}
.item {
width: 220px;
height: 250px;
margin: 10px auto;
padding: 0;
background: #ccc;
}
.item:nth-child(3n+2) {
background: #aaa;
height: 400px;
}
and the HTML I am just using a PHP loop to create 12 items
<?php
for ($i=0; $i<=11; $i++) {
echo '<div class="item"></div>';
}
?>
It is entirely possible.
Thanks to #leopld's original answer, I was able to create one that does not depend on a fixed height.
By making the flex container position: absolute or position: fixed, you are able to get it to fill the available space dynamically.
Link to the Codepen: http://codepen.io/anon/pen/Jpnyj?editors=110. I included all the vendor prefixes you'd need at this time.
Markup
<div class="wrapper">
<div class="box box-red"></div>
<div class="box box-blue"></div>
<div class="box box-pink"></div>
<div class="box box-purple"></div>
<div class="box box-green"></div>
<div class="box box-yellow"></div>
<div class="box box-brown"></div>
<div class="box box-red"></div>
<div class="box box-blue"></div>
<div class="box box-pink"></div>
<div class="box box-purple"></div>
<div class="box box-green"></div>
<div class="box box-purple"></div>
<div class="box box-green"></div>
<div class="box box-yellow"></div>
<div class="box box-blue"></div>
<div class="box box-pink"></div>
<div class="box box-purple"></div>
<div class="box box-green"></div>
<div class="box box-yellow"></div>
<div class="box box-red"></div>
<div class="box box-brown"></div>
<div class="box box-blue"></div>
<div class="box box-red"></div>
<div class="box box-green"></div>
<div class="box box-yellow"></div>
<div class="box box-brown"></div>
</div>
Styles
body {
background: black;
}
.wrapper {
position: absolute;
width: 100%;
height: 100%;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-flow: column wrap;
-ms-flex-flow: column wrap;
flex-flow: column wrap;
-webkit-box-align: stretch;
-webkit-align-items: stretch;
-ms-flex-align: stretch;
align-items: stretch;
-webkit-align-content: stretch;
-ms-flex-line-pack: stretch;
align-content: stretch;
}
.box {
margin: 5px;
-webkit-box-flex: 0;
-webkit-flex: 0 1 auto;
-ms-flex: 0 1 auto;
flex: 0 1 auto;
}
.box-red {
height: 100px;
background: red;
}
.box-blue {
height: 120px;
background: blue;
}
.box-pink {
height: 144px;
background: pink;
}
.box-purple {
height: 250px;
background: purple;
}
.box-green {
height: 200px;
background: green;
}
.box-yellow {
height: 20px;
background: yellow;
}
.box-brown {
height: 290px;
background: brown;
}
CSS3's columns will get you pretty close to that layout. (Note that support in non-recent browsers may be poor, and the spec may change in the future.) The other example didn't work with FF, but this one does:
HTML:
<div id="wrapper">
<div id="cols">
<div class="item">
<img src="http://placekitten.com/400/700?image=1" />
<p>0) Craft beer farm-to-table.</p>
</div>
<div class="item">
<img src="http://placekitten.com/400/450?image=2" />
<p>1) Mollit wolf veniam, leggings art party semiotics Brooklyn High Life sustainable occaecat Banksy actually.</p>
</div>
[more items]
</div>
</div>
CSS:
h1, h2, ul, p { margin: 1rem; }
#wrapper {
width: 900px;
margin: 20px auto;
padding: 10px;
outline: solid black 1px;
background-color: gainsboro;
}
#cols {
-webkit-column-count: 3;
-webkit-column-gap: 10px;
-moz-column-count: 3;
-moz-column-gap: 10px;
column-count: 3;
column-gap: 10px;
}
.item {
display: inline-block;
background: #FEFEFE;
margin: 0;
-webkit-column-break-inside: avoid;
-moz-column-break-inside: avoid;
column-break-inside: avoid;
padding: 10px;
}
.item img {
width: 100%;
border-bottom: 1px solid black;
padding-bottom: 10px;
margin-bottom: 5px;
}
.item p {
font-size:small;
margin: 0;
}
Or play with the full example.
Update: To my knowledge, there is no way of doing this with Flexbox. Flexbox is more concerned with horizontal layout, not vertical. I would be happy to be proven wrong, but that’s what I’ve gathered from my limited experience with it. If you want to learn more, the best article I’ve found on the matter is this: http://css-tricks.com/snippets/css/a-guide-to-flexbox/ (Yes, of course it’s Chris Coyier. How’d you ever guess?)
In any case, even if you can do it with Flexbox it would be a bit of a hack, because that isn’t what Flexbox is for. There’s a much cleaner way of doing it with CSS3 columns. Here’s an example.
Browser support isn't the greatest though: http://caniuse.com/#search=column%20layout Even this example doesn't seem to support Firefox, although I haven't a clue why, since FF does indeed support the respective properties, according to CanIUse.
So, a summary and TLDR: it's an admirable idea, doing this in pure CSS, but for most practical purposes is impossible at the moment. You would probably be better to go with JQuery Masonry
You can actually do it without any greater hassle using flexbox. The only drawback is that you have to specify an absolute height for the wrapper, in order to make the content of it actually wrap. Otherwise it would all be laid out along one great, never ending column.
The HTML:
<div class="wrapper">
<div class="red"></div>
<div class="blue"></div>
<div class="pink"></div>
<div class="purple"></div>
<div class="green"></div>
<div class="yellow"></div>
<div class="brown"></div>
</div>
The (unprefixed) CSS:
.wrapper {
background: black;
display: flex;
flex-flow: column wrap;
height: 450px;
align-items: center;
}
.wrapper > div {
height: 100px;
margin: 5px;
width: 100px;
}
.wrapper > :nth-child(3n+2) {
border: 2px solid white;
height: 300px;
}
I made a JS Fiddle as well, so you can see the result directly.
In a nutshell however, the trick is to use flex-direction: column in combination with flex-wrap: wrap and a fixed height for the wrapper.
I have to add, though - this seems like just the scenario that the CSS columns spec was written for, so KatieK's solution might be a better way to go. Above all, one doesn't need to specify a fixed height for the wrapper when using CSS columns instead of flexbox.