CSS: margin issues - php

I'm trying to output multiple elements in a single class, but i'm having trouble separating the top of page from the actual elements.
I've tried separating each image with div.element img:not(:nth-of-type(1)){ and div.element img:nth-of-type(1){ that didn't work. How would I manipulate the space between the first element, but not the others?
<div class="element">
<img src="http://website.com">
</div>
<div class="element">
<div id="Projecttitle" class="Projecttitle">Test Title</div>
</div>
<div class="element">
<div id="Projectdescription" class="Projectdescription">Test description</div>
</div>
<div class="element">
<img src="http://website.com">
</div>
<div class="element">
<div id="Projecttitle" class="Projecttitle">Test Title</div>
</div>
<div class="element">
<div id="Projectdescription" class="Projectdescription">Test description</div>
</div>

div.element:first-child {
padding-top: 0;
}
div.element {
padding-top: 10px;
}

Your HTML doesn't make sense. If you keep elements that logically belong together, you get semantic code that's much easier to style, like so:
<div class="project">
<div class="image">
<img src="#" alt="image">
</div>
<div class="text">
<h1>Test Title</h1>
<p>Test description</p>
</div>
</div>
And some CSS:
.image {
float: left;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
width: 50%;
padding: 10px 20px 10px 0;
}
.text {
float: left;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
width: 50%;
padding: 10px 0 10px 20px;
border-left: 1px solid black;
}
.project:first-child .image,
.project:first-child .text {
padding-top: 0;
}
.project:last-child .image,
.project:last-child .text {
padding-bottom: 0;
}
JSFiddle
That should get you started!

Try this:
div.element:nth-of-type(1) img {
padding-top: /* some value */;
}
The :nth-of-type(), and similar, pseudo-classes act on elements in the context of their parent. In other words, it only evaluates direct siblings. Your individual <img> elements are not siblings of each other, because they have different parents.

Related

How do I stack two landscape pictures on top of each other with a portrait picture on the side?

link to example
Getting the black portrait box is easy, but how do I create something like the two red boxes right on top of each other? I know one solution is to export the two landscapes with the gap as one image and put it in as a portrait but I'd prefer to not do it like that.
This is a start for you.
.row {
display: flex;
}
.row div {
width: 50%;
}
div {
margin: 20px;
}
img {
width:100%
}
<div class="container">
<div class="row">
<div class="first">
<img src="https://placehold.it/400x800/ccc/666?text=" class="img-responsive" alt="">
</div>
<div class="two">
<img src="https://placehold.it/400x400/ccc/666?text=" class="img-responsive" alt="">
<img src="https://placehold.it/400x400/ccc/666?text=" class="img-responsive" alt="">
</div>
</div>
</div>
<div class="main">
<div class="flexbox">
<div class="row"><img src="https://via.placeholder.com/150"/>
</div>
<div class="row image-wrapper">
<div class="col"><img src="https://via.placeholder.com/150"></div>
<div class="col"><img src="https://via.placeholder.com/150"></div>
</div>
<div>
</div>
.main {
width: 500px;
}
.flexbox {
width: 100%;
display: flex;
flex-wrap: wrap;
}
.col {
width: 100%;
height: 250px;
box-sizing: border-box;
padding: 10px;
}
.col img {
background: red;
width: 100%;
height: 100%;
}
.row {
width: 50%;
height: 500px;
padding: 10px;
box-sizing: border-box;
}
.row img {
background: black;
width: 100%;
height: 100%;
}
.row.image-wrapper {
padding: 0;
}
https://codepen.io/stargroup0075/pen/ExjMPXK

Wordpress - CSS styling not applying on a row

I'm currently building a site on Wordpress using the html5blank as the parent theme. I've built all the front-end text pages on HTMl/CSS. When I've transferred all the files over a lot of the styling has broken - I've fixed the majority of it but there's one section that I cannot fix. This is how it should look -
And this is how it looks in the Wordpress site -
When I've inspected the site via developer tools it seems as though these rules are not being applied -
.agencyproducts {
position: relative;
display: inline-block;
text-align: center;
}
Also, the row in the front-end site is applying a height rule but not in the wordpress site. I've looked at applying specificity rules and !important but nothing (this also disrupts other styling rules on other parts of the site). I'm really stuck on this and would appreciate any assistance.
Here's the full code for the section -
section#products {
height: 800px;
max-width: 100%
}
.agencyproducts {
position: relative;
display: inline-block;
text-align: center;
}
.agencyproducts p {
text-align: center;
margin: 30px;
}
.agencyproducts img {
width: 70px;
height: 70px;
position: relative;
line-height: 1;
top: 50%;
}
figure {
text-align: center;
display: inline-block;
max-width: 80px;
height: 100px;
vertical-align: top;
margin: 5px;
font-size: 9px;
margin-bottom: 60px;
}
figure img {
padding-bottom: 5px;
}
.four {
padding: 0;
margin: 0;
border: 0;
}
.images {
margin-top: 30px;
border-bottom: 10px;
}
.images img {
margin-left: 20px;
padding: 10px;
}
.chevron {
height: 150px;
}
.chevron figcaption {
margin-top: 20px;
font-size: 13px;
color: #d3d3d3;
}
hr.hragency {
display: block;
width: 250px;
margin-top: 0em;
margin-bottom: 0em;
margin-left: auto;
margin-right: auto;
border-style: inset;
border-width: 1px;
border-color: #F0F0F0;
}
<section id="products">
<div class="container">
<div class="row">
<div class="twelve columns agencyproducts">
<p>WHAT PRODUCT ARE YOU INTERESTED IN?</p>
<a href="2k4kproduction.html">
<figure>
<img src="images/production.png" alt="Production">
<figcaption>2K / 4K PRODUCTION</figcaption>
</figure>
</a>
<a href="postproduction.html">
<figure>
<img src="images/post-production.png" alt="Post-Production">
<figcaption>POST PRODUCTION</figcaption>
</figure>
</a>
<a href="2d3danimation.html">
<figure>
<img src="images/animation.png" alt="Animation">
<figcaption>2D / 3D ANIMATION</figcaption>
</figure>
</a>
<a href="adhoc.html"><figure>
<img src="images/ADHOC.png" alt="ADHOC">
<figcaption>ADHOC</figcaption>
</figure>
</a>
<a href="interactive.html">
<figure>
<img src="images/interactive.png" alt="Interactive">
<figcaption>INTERACTIVE & PERSONALISED</figcaption>
</figure>
</a>
<a href="tvadverts.html">
<figure>
<img src="images/tv-adverts.png" alt="TV ADVERTS">
<figcaption>TV ADVERTS</figcaption>
</figure>
</a>
<a href="360video.html"><figure>
<img src="images/360.png" alt="360 Video and VR">
<figcaption>360 VIDEO & VIRTUAL REALITY</figcaption>
</figure>
</a>
</div>
</div>
<hr class="hragency">
<div class="row">
<div class="images">
<div class="four columns">
<img src="images/VIDEO.jpg" alt="Video">
<img src="images/blog.jpg" alt="blog">
</div>
<div class="four columns">
<img src="images/faq.jpg" alt="FAQ">
<img src="images/VIDEO.jpg" alt="Video">
</div>
<div class="four columns">
<img src="images/blog.jpg" alt="blog">
<img src="images/faq.jpg" alt="FAQ">
</div>
</div>
</div>
</div>
</section>
<section class="chevron">
<div class="container">
<div class="row">
<figure>
<figcaption>SEE MORE</figcaption>
<i class="fa fa-chevron-circle-down fa-3x" aria-hidden="true"></i>
</figure>
</div>
</div>
</section>
Try this:
.agencyproducts{
width:100%;
text-align:center;
}
.agencyproducts a{
display:inline-block;
}
Because container .agencyproducts need to have text-align:center and first childs of it must be displayed as inline-block ... then they will display properly. You only set child of a tag as display:inline-block but do not tell CSS how it should treat it parent.
With what I understood try appending !important to your custom css properties so as to override any pre-existing style properties.
height: 150px !important;

How to overlay an image on other one with transperent effect using HTML-CSS

I want to overlay one image on other using CSS-PHP. Please see the below HTML and CSS snippet and give ur wise suggestions:
The images are present in header part of the division:
j_logo.jpg and MMPHero3.jpg. Of which former should be transparent and in left container while later one should occupy entire header region.
<body>
<div id="container">
<div id="header">
<div id="header-left-container">
<img src="j_logo.jpg" alt="jubilant"/>
</div>
<div id="header-right-container">
<img src="MMPHero3.jpg" alt="drug"/>
</div>
</div>
<div id="content"> Sidebar <p> </p>
<div class="form">
<p>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<p>Enter Drug Name </p>
<input type="text" name="drugName" value="<?php echo (isset($_POST['drugName']) ? $_POST['drugName'] : '') ?>">
<!--To retain search query after click added value="<?php echo (isset($_POST['drugName']) ? $_POST['drugName'] : '') ?>*/-->
<!-- This is commenting style in HTML -->
<p><input type="submit" value="search"></p>
</form>
</div>
</div>
<div id="sidebar"> Body
</div>
<div id="footer"> </div>
</body>
</html>
CSS style-sheet is below:
body {background: #ffffff;}
a {color: #2b2bf6;}
h1 {font-size: 30px;}
#container
{width:1000px;
margin: 0 auto;
background: #dddddd;}
#header
{height: 150px;
margin: 0px;
padding: 0px;
background: #FFFFA3;}
#header-right-container img
{border:none;
width:80%;
height:150px;
float: right;}
#header-left-container
{width:20%;
float: left}
#header-left-container img
{border:none;
width:100%;
height:150px auto;
float: left;}
#sidebar
{
position:relative;
width: 80%;
height: 400px;
float:right;
background: #FFFFA3; ;}
#content
{
position:relative;
width: 20%;
height: 400px;
float: left;
background: #f0e811;;}
#footer
{width: 100%;
height: 70px;
float: left;
background: #000000;
div.result
{
width:88%;
padding:5%;
border:5px solid gray;
margin:5px;
align:center;
}
div.form
{
width:180px;
padding:5%;
border:5px solid gray;
margin:50px;
align:center;
float:right;
}
table, td, th
{
border:0.5px solid blue;
align:center
}
th
{
background-color:#3886FC;
color:white;
}
I believe you should set the style to be something like "position:absolute; left:100px; top:100px; opacity:0.3;" for the image element on top.
Use style="opacity:0.5;" where opacity can be any val from 0.1 to 1
and for overlapping the img onto another you need to specify style="z-index:1;", the higher the z-index more priority will be given to it.

using flexbox to get pinterest or jQuery masonry layout

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.

CSS, rounded corners not working

I have two pictures on top of each other:
Here is the code:
<div class="picture">
<span class="name"><br/>Pavadinimas</span>
<div class="picture-content">
<div class="icons">
<div class="ico-info"><img src="images/product_mark_1.png" />
<span class="ico-info">Automatinis mechanizmas</span>
</div>
<div class="ico-info"><img class="ico-info" src="images/product_mark_2.png" />
<span class="ico-info">Miegamas mechanizmas</span>
</div>
<div class="ico-info"><img src="images/product_mark_3.png" /><br/>
<span class="info">Spyruoklės</span>
</div>
</div>
<div class="picture-grey"><img alt="" src="images/grey.png" />
</div>
</div>
<div class="picture-photo"><img alt="" src="images/pic.png" />
<div class="description1">
Ilgis/Plotis/Aukštis
</div>
<div class="description2">
Ilgis/Plotis
</div>
<div class="description3">
300/300/300
</div>
<div class="description4">
miegamoji dalis 100/100
</div>
</div>
</div>
I want the image at the top to be with rounded corners like this:
My css classes is:
.picture{
position:relative;
width:400px;
height:200px;
float:left;
margin-left:48px;
margin-right:35px;
margin-bottom:90px;
margin-top:10px;
}
.picture-content{
position:absolute;
bottom:0px;
width:360px;
height:211px;
}
.picture-grey{
position:absolute;
bottom:-65px;
left:15px;
height:243px;
width:407px;
float:left;
}
.picture-photo{
position:absolute;
width:380px;
height:223px;
-moz-border-radius: 50px;
-webkit-border-radius: 20px;
-khtml-border-radius: 20px;
border-radius: 20px;
top:0px; left:0px;
}
But unfortunately rounded corners is not working at all! Why not? Is there some issue I don't know?
you want your image round! not DIV!
.picture-photo img {
width:380px;
height:223px;
-moz-border-radius: 50px;
-webkit-border-radius: 20px;
-khtml-border-radius: 20px;
border-radius: 20px;
}
As an alternate answer, as long as the container .picture-photo wraps tight around the image (no visible padding), you can add the following CSS to hide the corners that are sticking out from the child element (the image):
.picture-photo {
overflow:hidden;
}
This is a old problem with firefox (and probably a few other browsers as well); it didn't crop the images until the latest firefox version:
Firefox -moz-border-radius won't crop out image?
Just out of curiosity, can you try the following?:
.picture{
position:relative;
width:462px;
height:305px;
margin:0px;
padding:0px;
background:url('http://i.stack.imgur.com/w0mOg.png') no-repeat;
background-position:50% 50%;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
-khtml-border-radius: 20px;
border-radius: 20px;
}
<div class="picture"></div>
I have the latest version of firefox so I can't check if it works on older versions as well, but it would make sense if it did. Firefox has been able to crop divs for quite some time.

Categories