I've been trying to create a 3 column layout containing cards that have a width of 1, 2 or 3 columns. To do this I've used CSS Grid with
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
My full code is here: Pen of the layout
I get some strange behaviour when the width of the container grows and shrinks. I would expect new columns to be added or removed based on the availability to add a new column of the minimum width (in this case 300px). THis doesn't seem to be happening - new columns are being added with a width <300px.
My SCSS is as follows:
.grid{
max-width:1020px;
margin:0 auto;
padding:10px;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
grid-auto-flow: dense;
grid-gap:10px;
}
.card{
padding: 5px;
background: #CCC;
grid-column: auto / span 1;
&:nth-child(2), &:nth-child(5) {
grid-column: auto / span 2;
}
&:nth-child(1), &:nth-child(6) {
grid-column: 1 / end;
}
}
Am I trying to do something that is beyond the capabilities of CSS Grid or am I doing something wrong in my code?
The issue is the implicit grid your are creating by defining grid-column:auto / span 2 which means that the element will take 2 columns so the grid need to at least contain 2 columns. When you the width is under 300px you explicitely create one column and the browse will implicitely create another one.
.grid {
max-width: 1020px;
margin: 0 auto;
padding: 10px;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
grid-auto-flow: dense;
grid-gap: 10px;
}
.card {
padding: 5px;
background: #CCC;
grid-column: auto / span 1;
}
.card:nth-child(2), .card:nth-child(5) {
/*grid-column: auto / span 2;*/
}
.card:nth-child(1), .card:nth-child(6) {
grid-column: 1 / end;
}
<p>Expected that new columns would only appear when 300px were available, but that doesn't seem to happen. New columns appear with much less available. Why???
<div class="grid">
<div class="card"><h1>grid-column: 1 / end</h1>Lorem ipsum dolor sit amet consectetur adipisicing elit. Veniam earum eum at nemo, illo voluptatem inventore, eveniet praesentium deleniti minus omnis saepe vitae explicabo similique natus? Est magnam aut veritatis?</div>
<div class="card"><h1>grid-column: auto / span 2;</h1>Id at accusantium, nisi error ipsa debitis corporis laudantium harum, dolorem odio beatae ad porro ullam perferendis tenetur odit eligendi, quisquam quasi rem? Placeat dolorum totam dignissimos tempore quia dolore?</div>
<div class="card"><h1>grid-column: auto / span 1;</h1>Provident maxime vitae perspiciatis voluptate quos rerum vel illo quas deleniti, voluptatem labore quibusdam. Eligendi, dolore, reprehenderit labore ipsum ipsam quod, nulla nihil harum dolor ipsa debitis quos officiis sed!</div>
<div class="card"><h1>grid-column: auto / span 1;</h1>Fugiat minus sequi vel commodi cum inventore in quae alias fuga quis voluptates perferendis nostrum tempore a maxime voluptas illo, officiis harum ipsam qui recusandae esse fugit asperiores. Architecto, eveniet.</div>
<div class="card"><h1>grid-column: auto / span 2;</h1>Quaerat delectus sint cumque inventore corporis alias consequatur totam nemo? Excepturi totam voluptatem voluptate! Exercitationem possimus amet voluptas corporis autem maiores nesciunt deserunt delectus! Ex praesentium ea debitis laborum doloribus.</div>
<div class="card"><h1>grid-column: 1 / end;</h1>Illo inventore perferendis officia nisi voluptatum temporibus nemo laudantium fuga suscipit? Aliquid nihil rem obcaecati vitae placeat temporibus cumque nostrum illum cum, ab dicta sequi voluptatum saepe, ut, voluptatibus suscipit.</div>
</div>
Removing this you will still have issue because of grid-column: 1 / end; which means that start from column 1 to the area named end but you didn't specify any area with that name so the browser will implicitely create one.
You can clearly notice for the above example that the last column is not following the logic of minmax(300px, 1fr) because it's the column created for end
I suspect you want to use grid-column: 1 / -1; which mean from 1 until the end:
.grid {
max-width: 1020px;
margin: 0 auto;
padding: 10px;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
grid-auto-flow: dense;
grid-gap: 10px;
}
.card {
padding: 5px;
background: #CCC;
grid-column: auto / span 1;
}
.card:nth-child(2), .card:nth-child(5) {
/*grid-column: auto / span 2;*/
}
.card:nth-child(1), .card:nth-child(6) {
grid-column: 1 / -1;
}
<p>Expected that new columns would only appear when 300px were available, but that doesn't seem to happen. New columns appear with much less available. Why???
<div class="grid">
<div class="card"><h1>grid-column: 1 / end</h1>Lorem ipsum dolor sit amet consectetur adipisicing elit. Veniam earum eum at nemo, illo voluptatem inventore, eveniet praesentium deleniti minus omnis saepe vitae explicabo similique natus? Est magnam aut veritatis?</div>
<div class="card"><h1>grid-column: auto / span 2;</h1>Id at accusantium, nisi error ipsa debitis corporis laudantium harum, dolorem odio beatae ad porro ullam perferendis tenetur odit eligendi, quisquam quasi rem? Placeat dolorum totam dignissimos tempore quia dolore?</div>
<div class="card"><h1>grid-column: auto / span 1;</h1>Provident maxime vitae perspiciatis voluptate quos rerum vel illo quas deleniti, voluptatem labore quibusdam. Eligendi, dolore, reprehenderit labore ipsum ipsam quod, nulla nihil harum dolor ipsa debitis quos officiis sed!</div>
<div class="card"><h1>grid-column: auto / span 1;</h1>Fugiat minus sequi vel commodi cum inventore in quae alias fuga quis voluptates perferendis nostrum tempore a maxime voluptas illo, officiis harum ipsam qui recusandae esse fugit asperiores. Architecto, eveniet.</div>
<div class="card"><h1>grid-column: auto / span 2;</h1>Quaerat delectus sint cumque inventore corporis alias consequatur totam nemo? Excepturi totam voluptatem voluptate! Exercitationem possimus amet voluptas corporis autem maiores nesciunt deserunt delectus! Ex praesentium ea debitis laborum doloribus.</div>
<div class="card"><h1>grid-column: 1 / end;</h1>Illo inventore perferendis officia nisi voluptatum temporibus nemo laudantium fuga suscipit? Aliquid nihil rem obcaecati vitae placeat temporibus cumque nostrum illum cum, ab dicta sequi voluptatum saepe, ut, voluptatibus suscipit.</div>
</div>
To better illustrate both issues, here is a simplifed example for the first one:
.box {
display:grid;
grid-template-columns:100px; /* I defined one column*/
grid-gap:10px;
}
.box span:first-child {
grid-column:span 2; /* I will create another column*/
}
.box span {
height:50px;
background:red;
}
<div class="box">
<span></span>
<span></span>
</div>
And for the second one:
.box {
display:grid;
grid-template-columns:100px; /* I defined one column*/
grid-gap:10px;
}
.box span:first-child {
grid-column:1/ a_radom_name; /* I will create another column*/
}
.box span {
height:50px;
background:red;
}
.box span:last-child {
grid-column-end:a_radom_name; /* I can place other element on that column */
}
<div class="box">
<span></span>
<span></span>
</div>
If you inspect the grid you will notice that we will end with 2 columns (one implicit and one explicit)
The three properties grid-template-rows, grid-template-columns, and grid-template-areas together define the explicit grid of a grid container. ref
When grid items are positioned outside of these bounds, the grid container generates implicit grid tracks by adding implicit grid lines to the grid. These lines together with the explicit grid form the implicit grid. ref
Related
How can I make the green background to cover all the .section class?
I have this structure:
section // one section will have one container
->container // one container can have multiple elements
->elements // the background class set here should override the section
relation everywhere and I would like to define a "background" element that covers the whole section.
Note:
I am getting the data like(section/container/elements) this and it is not going to change.
There is possible to have multiple sections each with it's own background.
.section {
width: 100%;
background-color: yellow;
}
.container {
height: 300px;
padding: 30px;
margin: 100px;
background-color: red;
}
.background {
width: 100%;
height: 100%;
}
.red {
background: red;
}
.green {
background: green;
}
<div class="section">
<div class="container">
<div class="background green" />
<div>
some content
</div>
</div>
</div>
Link to jsfiddle
you Should style give tag section
background-color: green;
You could set the position of .section to relative, and set the position of .green to absolute.
Now the position, width & height will use .section as reference.
Then you could set these properties freely.
here is the code:
.section{
position: relative;
}
.green {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
}
and then you may have to adjust their z-index
.green {
z-index: -1;
}
.section {
z-index: 0;
}
absolute: The element is removed from the normal document flow, and no space is created for the element in the page layout. It is positioned relative to its closest positioned ancestor, if any; otherwise, it is placed relative to the initial containing block. Its final position is determined by the values of top, right, bottom, and left. MDN
One approach, with explanatory comments in the code, is as below:
/* simple reset to ensure no browser-default padding/margin exists,
and forces all element-size calculations to include border-width
and padding inside the defined width: */
*,::before, ::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
.section {
/* all values here are purely aesthetic, adjust to your own
requirements: */
border: 2px solid #000;
height: 80vmin;
width: 80vmin;
margin-block: 1em;
margin-inline: auto;
}
.container {
/* here we use grid layout on the .container element(s): */
display: grid;
/* we specify one grid-column and one grid-row, each of which
take 100% of the available space: */
grid-template-columns: 1fr;
grid-template-rows: 1fr;
/* sizing the grid to be 100% of the parent's width/height: */
width: 100%;
height: 100%;
}
/* all <div> elements that are children of the .container: */
.container > div {
/* are placed in the first grid-column and first grid-row: */
grid-column: 1;
grid-row: 1;
/* specifying a max-height and max-width of 100% to address
potential overflow; obviusly adjust to your requirements: */
max-height: 100%;
max-width: 100%;
}
/* styling the element that will hold the contents (so far as your
demo shows): */
.container > div:last-child {
/* hiding overflow on x-axis: */
overflow-x: hidden;
/* allowing scrolling on the y-axis to see
overflowing content: */
overflow-y: scroll;
/* defining some white-space between the element edges and contents
within: */
padding: 0.5em;
}
.blue {
background-color: hsl(180 65% 81% / 0.5);
}
.green {
background-color: hsl(120 93% 79% / 0.5);
}
.yellow {
background-color: hsl(60 100% 50% / 0.5);
}
<div class="section">
<div class="container">
<div class="background blue" />
<div>
Some very short content
</div>
</div>
</div>
<div class="section">
<div class="container">
<div class="background green" />
<div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Placeat corporis hic sunt nam perferendis assumenda asperiores nobis quae consequatur aut ut quidem id, optio consequuntur ipsa labore consectetur nihil incidunt.</p>
<p>Minima quibusdam hic culpa, ea porro vitae asperiores! Vitae odit, delectus nesciunt asperiores maxime. Voluptatum velit repellendus in. Impedit laudantium asperiores nostrum neque laboriosam eius libero fugiat itaque inventore nulla?</p>
<p>Laboriosam quod, facilis ratione quas consequatur quis quisquam vel eius velit eveniet, excepturi voluptatem ea dicta quam eaque praesentium sequi illum, optio animi! Libero minima iste, maiores temporibus reiciendis repellendus.</p>
<p>Blanditiis reiciendis eveniet perspiciatis excepturi, nulla eum, rem atque. Perspiciatis quae sed autem officiis error, earum officia, nulla quod, velit deleniti pariatur. Obcaecati inventore, in adipisci eveniet, expedita a quaerat.</p>
<p>Quaerat labore vitae iure expedita eaque nostrum distinctio et, atque velit quisquam corporis animi, aut voluptatem itaque odio ipsum. Iusto asperiores eius at quos totam voluptatum, ratione voluptate cum quas.</p>
<p>Sed minima aliquid voluptatum minus dolores, iusto, ducimus doloribus! Aliquam quae, atque! Iusto nobis alias magnam minima, impedit iste illo iure illum doloremque debitis! Ipsa assumenda soluta fugiat ut esse.</p>
<p>Sint voluptatum suscipit laborum, aliquid eveniet odit blanditiis corporis voluptatibus, rem consectetur quam quidem saepe, doloremque, sit nihil rerum voluptas deleniti a expedita quo quod beatae modi. Incidunt, aliquid. Ea.</p>
<p>Minus, dicta sed maiores amet necessitatibus eaque magnam asperiores, aperiam, qui earum numquam sequi eius provident officiis. Illum fuga earum architecto nesciunt ut beatae mollitia quod sunt nulla. Ipsum, modi?</p>
<p>Eligendi, officiis maxime cupiditate consectetur voluptates est ullam odio, porro sint cum suscipit rerum nisi quibusdam non enim repudiandae facere fugiat repellendus possimus, sequi excepturi culpa iusto. Velit, sunt deleniti!</p>
<p>Ipsa deserunt dolorum molestias reiciendis. Ad dolorum eius suscipit, sapiente laboriosam dolor sequi, accusamus id consequuntur modi aliquid, architecto fuga illum non voluptatum quod. Molestiae deserunt maxime suscipit tenetur, tempora.</p>
<p>Id non fugit in vitae. Fuga voluptates sapiente, impedit atque, quasi, consequatur autem sunt dignissimos unde nam quam! Officiis quos, distinctio facilis illum explicabo incidunt quia pariatur minima, enim at.</p>
<p>Commodi consectetur repellendus ad assumenda eius voluptatibus tempora dolor et possimus quaerat aperiam nesciunt qui optio, sapiente ab libero iste, recusandae, suscipit obcaecati accusamus perferendis minus molestias. Nisi, inventore, explicabo?</p>
</div>
</div>
</div>
<div class="section">
<div class="container">
<div class="background yellow" />
<div>
Some very short content
</div>
</div>
</div>
JS Fiddle demo.
References:
box-sizing.
CSS Pseudo-elements.
display.
grid-column.
grid-row.
grid-template-columns.
grid-template-rows.
hsl().
:last-child.
margin.
margin-inline.
margin-block.
max-height.
max-width.
overflow.
overflow-x.
overflow-y.
padding.
vmin.
width.
I have a page layout that works exactly the way I want it... But for another page, I have some content and want to automatically adjust the height of the row they are in. For example I want to expand it like that;
I want to expand the "left2" height depending on the "right2" height. But don't want to change the "left1", "right1" and "footer" heights...
.project-container {
display: grid;
height: 100vh;
grid-template-columns: 4fr 3fr;
grid-template-rows: 7fr 4fr 2fr;
grid-template-areas:
"left1 right1"
"left2 right2"
"footer right2";
}
.left1 {
grid-area: left1;
background-color: red;
}
.left2 {
grid-area: left2;
background-color: blue;
}
.footer {
grid-area: footer;
background-color: purple;
}
.right1 {
grid-area: right1;
background-color: green;
}
.right2 {
grid-area: right2;
background-color: orange;
font-size: 2vw;
}
<div class="project-container">
<div class="left1"></div>
<div class="left2"></div>
<div class="footer"></div>
<div class="right1"></div>
<div class="right2">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?
</div>
</div>
codepen
I am attempting to have text wrap onto the next line but instead of wrapping the text directly beneath the first line, have it wrap and begin at the far left of the viewport. Is this possible?
<div class="wrapper">
<p>some text</p>
<span> / </span>
<p class="some-long-text">this is an unnecessarily long string that will wrap to the next line on small devices</p>
</div>
.wrapper {
display: flex;
flex-direction: row;
flex-wrap: wrap;
> { display: flex; }
.some-long-text {
word-break: break-word;
white-space: inherit;
text-align: left;
}
}
This is essentially what I'm seeing:
It is possible. I think this might be what you are looking for.
.some-text {
display: inline;
}
.span-div {
float: left;
}
.slash {
padding: 0 1rem;
}
<span class="span-div"><p class="some-text">some text</p><span class="slash">/</span></span><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quam reprehenderit vel dolores, neque perspiciatis repellendus quasi assumenda, eaque incidunt totam at officiis qui, sunt facere eveniet aliquid optio, officia atque tenetur odit iste expedita. Est officia cum, nisi, voluptatum consequuntur veniam. Suscipit excepturi repellat, adipisci delectus, unde consequatur impedit amet vero voluptates minus voluptatum aut alias, quod. Quaerat doloribus numquam alias veniam fugiat, recusandae debitis ad atque ipsam esse sit nostrum, dignissimos accusamus facere minima reiciendis rem repellendus iusto, nesciunt perferendis sequi. Voluptatum nesciunt enim et explicabo, laudantium optio iusto expedita fugiat dolores, at debitis molestiae autem, eius totam incidunt!</p>
I have a container with lots of content and hence I have set overflow: auto; to make it scrolling.
I also need a button in the bottom-right corner of this container at a fixed position (similar to a FAB button in Material Design).
The button is nicely placed in the bottom-right of the container. Unfortunately when I scroll the content, the button moves with it. My understanding of absolute positioning is that it will position the element relative to its parent (with position: relative;). So why is this button moving? What's the right way to fix it to the parent?
The expected behavior is that the button stays in the bottom-right corner regardless of the scroll position. For an example, see this page and search for the phrase "Animation of toolbar off-screen during scrolling".
Note that I am looking to make this work with absolute positioning, not fixed positioning. The button should be in bottom-right corner of its container, not matter how deeply the container is nested in the browser window.
* {
box-sizing: border-box;
}
.container {
position: relative;
overflow: auto;
height: 256px;
width: 256px;
margin-right: 16px;
border: solid 1px red;
padding: 4px;
}
.fab {
position: absolute;
right: 20px;
bottom: 20px;
color: white;
background-color: blue;
}
<div class="container">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aspernatur mollitia maxime facere quae cumque perferendis cum atque quia repellendus rerum eaque quod quibusdam incidunt blanditiis possimus temporibus reiciendis deserunt sequi eveniet necessitatibus maiores quas assumenda voluptate qui odio laboriosam totam repudiandae? Doloremque dignissimos voluptatibus eveniet rem quasi minus ex cumque esse culpa cupiditate cum architecto! Facilis deleniti unde suscipit minima obcaecati vero ea soluta odio cupiditate placeat vitae nesciunt quis alias dolorum nemo sint facere. Deleniti itaque incidunt eligendi qui nemo corporis ducimus beatae consequatur est iusto dolorum consequuntur vero debitis saepe voluptatem impedit sint ea numquam quia voluptate quidem.
<Button class="fab">
Ok
</Button>
</div>
Please see my JSFiddle here
There are many ways of achieving this, but I would prefer wrapping the .container with a .container-parent of the same height and width, and position: relative. This gives you a non-scrolling element to position the .fab button against.
<div class="container-parent">
<div class="container">
Lorem ipsum dolor sit amet...
</div>
<Button class="fab">
Ok
</Button>
</div>
With CSS:
.container-parent {
position: relative;
height: 256px;
width: 256px;
}
.fab {
position: absolute;
bottom: 20px;
right: 20px;
}
Here's the fiddle: http://jsfiddle.net/t702Lknz/4/
Alternatively, you could use your original markup, with .fab having a fixed position. The CSS would be like:
.fab {
position: fixed;
top: 225px;
left: 190px;
}
Here's the fiddle for that: http://jsfiddle.net/t702Lknz/3/
You can do this by adding a wrapper div for the text. The wrapper div will its width and height set to 100% and overflow set to auto, so it will have the scroll box and your FAB can be positioned within the outer div like so:
* {
box-sizing: border-box;
}
.fab {
position: absolute;
right: 20px;
bottom: 20px;
}
.container {
position: relative;
border: solid 1px red;
height: 256px;
width: 256px;
float: left;
margin-right: 16px;
}
.text-wrapper {
overflow: auto;
height: 100%;
width: 100%
}
<div class="container">
<div class="text-wrapper">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aspernatur mollitia maxime facere quae cumque perferendis cum atque quia repellendus rerum eaque quod quibusdam incidunt blanditiis possimus temporibus reiciendis deserunt sequi eveniet necessitatibus
maiores quas assumenda voluptate qui odio laboriosam totam repudiandae? Doloremque dignissimos voluptatibus eveniet rem quasi minus ex cumque esse culpa cupiditate cum architecto! Facilis deleniti unde suscipit minima obcaecati vero ea soluta odio
cupiditate placeat vitae nesciunt quis alias dolorum nemo sint facere. Deleniti itaque incidunt eligendi qui nemo corporis ducimus beatae consequatur est iusto dolorum consequuntur vero debitis saepe voluptatem impedit sint ea numquam quia voluptate
quidem.
</div>
<Button class="fab">
Ok
</Button>
</div>
I finally figured out how to do this. Since only the text should scroll, it should be inside its own scrolling container. This makes the button latch on to its parent without being affected by the scrolling. Here's the final code.
* { box-sizing: border-box; }
.container {
/* keep the add button in a fixed location relative to this container */
position: relative;
display: flex;
flexDirection: column;
height: 200px;
width: 200px;
margin-right: 16px;
border: solid 1px red;
padding: 4px;
}
.text-container {
/* ensure that only the text scrolls, not the button */
flex: 1;
overflow: auto;
}
.fab {
position: absolute;
right: 20px;
bottom: 20px;
color: white;
background-color: blue;
}
<div class="container">
<div class="text-container">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aspernatur mollitia maxime facere quae cumque perferendis cum atque quia repellendus rerum eaque quod quibusdam incidunt blanditiis possimus temporibus reiciendis deserunt sequi eveniet necessitatibus maiores quas assumenda voluptate qui odio laboriosam totam repudiandae? Doloremque dignissimos voluptatibus eveniet rem quasi minus ex cumque esse culpa cupiditate cum architecto! Facilis deleniti unde suscipit minima obcaecati vero ea soluta odio cupiditate placeat vitae nesciunt quis alias dolorum nemo sint facere. Deleniti itaque incidunt eligendi qui nemo corporis ducimus beatae consequatur est iusto dolorum consequuntur vero debitis saepe voluptatem impedit sint ea numquam quia voluptate quidem.
</div>
<Button class="fab">
Ok
</Button>
</div>
So the body of my page has some white space on each side, and I would like my header logo to be aligned on the left so that no matter what size the window is, it will vertically start at the same place the body does.
I can not figure out how because the body is centered, but has a percentage width, while my header logo is natively in the middle, and floating it to the left and adding a margin/padding (no matter if it is percentage or pixel) does not make it responsive to larger screens than my laptop.
The css for my container is:
.td-container {
width: 95%;
max-width: 1350px;
margin-right: auto;
margin-left: auto;
}
And so far for my header, I have tried:
.td-main-logo img {
max-width: 1350px;
margin-right: auto;
margin-left: auto;
}
and:
.td-main-logo img {
max-width: 1350px;
margin-left: 6%;
}
Body tag has margin around it. Try to reset it to "hide" white space.
CSS
body {margin:0}
Tips,
margin-left:auto and margin-right:auto is same as margin:auto
try to use box-sizing:border-box with padding (https://www.google.cz/search?q=box-sizing%20css)
LIVE EXAMPLE: http://codepen.io/anon/pen/oBMBax
(You haven't provided more informations)
What about this? I have changed the width to 600px just for demo purposes (same the outline)
.td-main-logo,
.td-container {
width: 95%;
max-width: 600px;
margin-right: auto;
margin-left: auto;
}
.td-container,
.td-main-logo{
outline: 1px solid red;
}
<div class="td-main-logo">
<img src="https://upload.wikimedia.org/wikipedia/commons/a/ab/Logo_TV_2015.png" width="100px">
</div>
<div class="td-container">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nesciunt nihil consequuntur, quasi dicta officiis distinctio, aliquid soluta provident tempore magni temporibus autem, facilis voluptatum ab blanditiis fuga tempora vel tenetur officia voluptate. Quaerat dolor magnam, dolore sint id ducimus ea optio rem nobis doloremque quam animi quidem veritatis assumenda commodi, ratione aspernatur. Ad nemo eos at quis quos saepe numquam, tempora blanditiis minus, pariatur soluta unde dolorem aut beatae esse nam, accusamus dolore rerum quam necessitatibus aspernatur explicabo doloremque. Quae rem error quia facilis deleniti asperiores excepturi numquam illum quo. Eius cupiditate laudantium molestiae ex ipsam perspiciatis, nam! Beatae tempora iure aliquid accusamus illum, adipisci? Ducimus praesentium commodi, aspernatur debitis voluptate omnis nemo quia illo magnam quis voluptates, ullam laborum tenetur dolorum ut. Molestias ex quas ea, excepturi praesentium error, natus ut quaerat porro, tenetur dolorum eaque exercitationem hic officiis repellat est suscipit dolor dolore velit. Doloribus rerum porro deserunt.
</div>
`