How do I ensure that the images and text are responsive? - php

I want to have 3 movies per row and for the texts below to be on the centre relative to the image.
Currently, my website looks like this (please ignore the red box, it is just for me to see the size)
In addition, when I resize my page, the title and the texts get shifted all over. How do I prevent this from happening and ensure that everything is responsive?
Codes in PHP file:
<div class="col-md-3 row movieBox">
<img src="'.$sub_row["image"].'" class="img-responsive img-thumbnail"/>
<h4>'.$sub_row["title"].'</h4>
<p>'.$sub_row["movie_warning"].'</p>
<p>'.$sub_row["movie_duration"].'</p>
</div>
Codes in CSS:
.movieBox{
float: left;
display: flex;
padding: 50px;
margin: auto;
margin-bottom: 10px;
position: relative;
border: 1px solid red;
}
/*Responsive layout - makes a two column-layout instead of four columns */
#media screen and (max-width: 900px) {
.column {
width: 50%;
}
}
/* Responsive layout - makes the two columns stack on top of each other instead of next to each other */
#media screen and (max-width: 600px) {
.column {
width: 100%;
}
}

You do not need float: left; or position: fixed; on either selector.
Flex is attempting to fit as many boxes as possible in the available width. By default it will shrink the elements as much ass possible. To fix that you can add a width to your elements and use flex-wrap to make the content wrap.
Try something like this:
.Row{
display: flex;
border: 1px solid red;
flex-wrap: wrap;
justify-content: space-between;
}
.Column{
width: 33%;
flex-shrink: 0;
display: flex;
padding: 50px;
border: 1px solid red;
}

You should use CSS Grid to get the desired result. Firstly, create a three-column layout with:
.container {
display: grid;
grid-template-columns: repeat(3, 1fr); /*this will create 3 equal columns*/
grid-template-rows: auto;
grid-gap: 1em; /*add only if you want to add some space in between the red boxes*/
}
Adding this, the items inside container class will arrange themselves in rows of threes.
Now, for the responsiveness, use media queries.
#media screen and (max-width: 480px) {
.container {
grid-template-columns: 1fr; /*one-column for mobile devices*/
}
}

You need two steps:
1- Use flex layout or grid layout.
2- Use media queries.
This simple example may help you CSS Flex Responsive

Related

How to increase product image size in grid view in Opencart?

I cannot increase product gridview image size. Though I have increased list view image size by going to Admin->Extensions->Extensions->Themes and thereby editing default store theme. Here I can edit Product Image List Size. But here is no mention of Product Image Grid Size.
I do not know where to edit product image grid size. The List size has been increased but of no use because when someone opens the product, the default view is Grid View which is not increased. Though the List Size is increased but someone cannot see bigger image unless one does not click the List size because the default view when someone opens a product is grid view.
How can I increase image size in grid view? I am using default theme with OC 3.0.2.0.
Please note that there is this CSS property (from bootstrap) that does not allow the images to be larger than the product box:
max-width: 100%;
The product box in the grid view has some col class like this:
<div class="product-layout product-grid col-lg-4 col-md-4 col-sm-6 col-xs-12">
You can remove those classes from the twig file, like this:
<div class="product-layout product-grid">
Or you can add this CSS code:
.product-grid {
width: auto;
float: none;
clear: none;
}
At the bottom of stylesheet.css to override the bootstrap column width:
catalog/view/theme/default/stylesheet/stylesheet.css
Then you may need to clear the theme caches and the browser caches to see the change.
Well, but an opencart doesn't provide any other image settings.
You could find out by looking into your stylesheet.css file, and possibly find different layout settings for product-list and product-grid Sections.
Then, you could add some min- or max-height/width or then a 'fixed' height/width image size Values to the individual Sections in the right places, to find out if it works. Still the responsive Function might still resize the images to a smaller Value, if no min-value has been set, but not to a larger one, and only, if a screen resolution gets smaller.
That's all I can do for you, and the time invested only depends on how complicated
the Theme Coder worked. And depending on how it's been coded, it might not be
possible either, without a fundamental rewrite of the sections involved. Don't forget to make a backup copy of the stylesheet first! But don't worry, you cannot ruin anything. And make sure, to always first RESET your entire Cache Systems, as well as the browser Cache, before testing for results.
Sample of such a Stylesheet section:
/* product list */
.product-thumb {
border: 1px solid #ddd;
margin-bottom: 20px;
overflow: auto;
}
.product-thumb .image {
text-align: center;
margin: 10px;
}
.product-thumb .image a:hover {
opacity: 0.8;
}
.product-thumb .image img {
margin-left: auto;
margin-right: auto;
}
.product-grid .product-thumb .image {
float: none;
}
#media (min-width: 767px) {
.product-list .product-thumb .image {
float: left;
padding: 0 15px;
}
}
.product-thumb h4 {
font-weight: bold;
}
.product-thumb .caption {
padding: 0 20px;
min-height: 60px;
}
.product-list .product-thumb .caption {
margin-left: 230px;
}
#media (max-width: 1200px) {
.product-grid .product-thumb .caption {
min-height: 210px;
padding: 0 10px;
}
}
#media (max-width: 767px) {
.product-list .product-thumb .caption {
min-height: 0;
margin-left: 0;
padding: 0 10px;
}
.product-grid .product-thumb .caption {
min-height: 0;
}
}

How can i make the horizontal navigation menu center aligned

I am creating a Wordpress theme based on the Twenty Eleven theme and can't figure out how to have the navigation bar center automatically so I won't have to constantly update it.
Here is my CSS:
http://pastebin.com/SGvKmXEb
Here is the PHP/HTML:
http://pastebin.com/TBL1nzjV
There may be duplicate properties in the CSS, but only because I am still experimenting with this and testing multiple things...
Thanks in advance for the help!
This Worked for me on the test site you provided
#access li {
float: left; /*delete*/
display:block; /*delete*/
display:inline-block; /*add*/
}
#access ul {
margin-left: 25%; /*delete*/
margin-right: 25%; /*delete*/
width: 1000px; /*delete*/
height: 10px; /*delete*/
margin-bottom: 0px; /*add*/
margin-left: 0px; /*add*/
padding: 0px; /*add*/
}
I'd choose an inline-block approach.
.containerElement {
width: 100%;
text-align: center;
}
.childElements {
display: inline-block;
}
In order to make it work in your code, you need to remove .containerElement (#access ul) fixed height, and .childElements (#access li) floating property.

CSS how to align text inside sidebar

Well, I have sidebar but text(in my case tables) inside sidebar are not aligned like I want.
From one .php I call another inside sidebar, like this:
<div id="sidebar2"> <?php include("tiket.php");?></div>
Here is it CSS of sidebar:
#sidebar2 {
width: 240px;
float: right;
padding: 40px;
background: #264988;
color: #e1d2c7;
margin: 5px;
text-align:justify;
}
An this is how it looks:
How to put text on the left of the sidebar?
It would help a lot if you gave us the complete source code of the sidebar, or told us where it was located.
I think that the reason why the text is not aligned to the left is because you put in text-align:justify;. Remove that line.
#sidebar2 {
width: 240px;
float: right;
padding: 40px;
background: #264988;
color: #e1d2c7;
margin: 5px;
}
What justify does is spread the text out evenly, which can be unhelpful if you don't have much text.
You can nest with CSS3
#sidebar2 table {
text-align: left;
}
you can read more about it over here
https://www.w3schools.com/css/css_combinators.asp

Gallery Image Transition

I wonder whether someone may be able to help me please.
I'm using Aurigma Image Uploader and FancyBox to produce this gallery page. The problem I'm having is that the images are positioned to go vertically down the page, whereas I would prefer them to go horizontally across the page, creating separate rows of images, one underneath the other.
I appreciate that some may not know anything about the Aurigma package, but I think I'm right in saying that 'Fancybox' is a little more widely used.
I just wondered whether someone could perhaps provide somne guidance please on the settings I would need to change within the Fancybox script so that the images are positioned horizontally rather than vertically.
Many thanks
.ccs file extract
.gallery-image-list { padding: 0; list-style-type: none; }
.gallery-image-list .item { display: inline-block; vertical-align: top; margin: 5px; padding: 15px; white-space: nowrap; width: 150px; float:left; }
.gallery-image-list .wide-item { width: 250px; }
.gallery-image-list .item .preview { display: inline-block; vertical-align: top; }
.gallery-image-list .item .data { margin: 5px; padding: 5px; list-style-type: none; display: inline-block; vertical-align: top; font-size: 95%; }
.gallery-image-list .item .data li { margin-bottom: 5px; }
I think what you want is to add float:left; to your item class in css.

Vertical-Align a DIV

This is the code for my next/prev navigation found at http://ilikeyou.tk/763/ :
<div class="navigation">
<? if($nexts['id'] == ''){ ?>
<? }else{ ?>
<? } ?>
</div>
I would like to vertically center the buttons. I tried using vertical-align:middle; which didn't work. I also tried top:50%; but that didn't do the job either.
Here is my css:
.navigation {
position: relative;
float: left;
vertical-align : middle;
height: auto;
padding: 0;
margin: 0 -20px 0 -22px;
width: 636px;
z-index:1;
}
.navigation a.prev{
background: url('images/nav_left.png');
float: left;
width: 50px;
height: 50px;
margin-left:10px;
}
.navigation a.next {
background: url('images/nav_right.png');
float: right;
width: 50px;
height: 50px;
margin-right:10px;
}
Thanks!
So, I'm guessing that the content area height is not very static.
http://jsfiddle.net/aBzhu/
Trick is to have the outer element set to position: relative; float: left; and then the element you want to center as position: absolute; top: 50%; margin-top: -Half_the_height_of_this_element;
Note that this only works when the element that you want to center vertically IS static height. Should fit your usage I think.
Edit: Oh.. and I dont think this necessarily works in ie6. But does work ie7+
Edit2: Also if youre not interested in such a puny methods you should check this out Using jQuery to center a DIV on the screen
vertical-align is intended for table cell rendering, and even this is quite problematic. Why not just add a few pixels of top padding to your navigation ul? It's not real centering, but you're obviously not worried about dunamic scaling when you're using a fixed height graphic for the navigation background.
This Solution Matched me perfectly for small texts. Even if it is a link or just a text inside the div, this CSS Class could vertically align the content inside the DIV. Works for IE as well..
.verticalCenterDivText{
height: 29px;
line-height: 29px;
}
Hope this helps....
Regards, ADynaMic

Categories