Tips on concealing all elements besides the one with the ID of "mainContainer"

Efforts have been made to conceal everything except the main content on this particular Facebook post

The following CSS code has been attempted without success - I would appreciate any assistance.

html body * {
 display:none;
}

#contentArea {
 display:block;
}

Displayed below is a screenshot of the desired outcome. https://i.sstatic.net/vY4UX.png

Answer №1

Using the CSS selector body *, you can hide all child elements on a webpage.

If you use #contentArea to show a specific block, the styles applied by body * will still affect both child and parent elements.

To completely hide everything else on the page, you'll need to define more specific rules in your CSS.

Answer №2

It's worth noting that displaying an element with a hidden parent is not possible, as previously mentioned. Surprisingly, Facebook's layout turned out to be simpler than expected - you just need to hide the header and sidebar elements if the user is not logged in.

Simply inject this CSS:

#pagelet_bluebar, #rightCol {
    visibility: hidden;
}

Here is the result:

https://i.sstatic.net/QOJqk.jpg

And this is the result if the user is logged in:

https://i.sstatic.net/xaY5d.jpg

If you want to hide the chat sidebar, include #pagelet_sidebar in your CSS:

#pagelet_bluebar, #rightCol, #pagelet_sidebar {
    visibility: hidden;
}

In conclusion, focus on hiding the main components rather than everything on the page, or utilize jQuery to target all elements except for your specific one, as suggested by @MaVRoSCy.

Answer №3

Big shoutout to everyone for your input - here's the ultimate mix of all the suggestions:

#leftCol, #pagelet_bluebar, #rightCol, #pagelet_bluebar {
    visibility: hidden !important;
    display: none !important;
}

html ._5vb_.hasLeftCol #contentCol {
    border-left: initial  !important;
    margin-left: initial   !important;
    padding-left: initial  !important;
    padding-top: initial  !important;

}

._5vb_, ._5vb_ #contentCol {
background: none !important;
}

https://i.sstatic.net/m12rd.png

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Struggling to create a mobile-friendly design

I've successfully created a dynamic world map using D3.js, but I need some guidance on making it responsive across various screen sizes. You can view the interactive world map here. Credentials to access the map: Username: DXLdemo Password: ...

Having trouble displaying a background image on a React application

Public>images>img-2.jpg src>components>pages>Services.js> import React from 'react'; import '../../App.css'; export default function Services() { return <h1 className='services ...

Bootstrap's (g-) gap feature seems to be malfunctioning, unfortunately

Even though I followed the grid structure from Bootstrap reference, my code doesn't seem to have horizontal gaps, only vertical ones. I know it's not about the version because when I copy and paste the sample code into my HTML file, that code sti ...

html css javascript, Is it possible to execute a script before a webpage finishes loading?

My current setup is similar to a lightbox feature, but I'm facing an issue where the script waits for the entire webpage to load before running. Is there a way to ensure that my script runs first without waiting for the webpage to fully load? CSS: # ...

Creating animated effects through Javascript and CSS triggered by user events

As a beginner in javascript and CSS, I am experimenting with creating a simple animation that adjusts the transparency of an image when triggered by an event. However, I am facing an issue where the animation only works every other time the function is cal ...

Numerous websites with scroll-based navigation

I am currently building a unique website that includes scrolling in various directions without the use of a horizontal scrollbar. The design is similar to this image: https://i.stack.imgur.com/Ex2Bf.jpg. It is a one-page website where vertical scrolling ...

Updating the iFrame source using jQuery depending on the selection from a dropdown menu

I want to create a dynamic photosphere display within a div, where the source is determined by a selection from a drop-down menu. The select menu will provide options for different rooms that the user can view, and the div will contain an iframe to showca ...

Dealing with the overflow issue on Android 4.1 using position: relative and position: absolute

I have a question regarding creating a dynamically filling rounded button. I have successfully created an inner div inside the button with absolute positioning at the bottom. It works perfectly on Chrome webview, but I'm facing issues on Android 4.1. ...

Explore the world of interior CSS border styles

Trying to achieve a unique border effect like the one shown in the image. Experimented with different styles such as inset, outset, ridge, and groove, but unable to get the desired outcome. Is there a way to create a border that bends inwards towards the m ...

Adjusting the size of images in a Bootstrap lightbox gallery

I am currently working on a website for an artist, making the galleries a key aspect. The website is built using Bootstrap, with the Lightbox for Bootstrap plugin being used for the galleries. Everything seems to be working well in terms of adjusting the i ...

Utilize SCSS values within TypeScript by applying them on a class level

let changeClassDisplay = document.getElementsByClassName('sidebar'); for (var i = 0; i < changeClassDisplay.length; i += 1) { changeClassDisplay[i].style.display = 'block'; } I encountered an issue with this code whe ...

Ensure that Bootstrap4 cards are fully stretched to a width of 100%

Does anyone know how to make Card2 and Card3 in Bootstrap4 stretch to 100% width? Card1 defines the total height, but Card2 and Card3 are not taking up the full remaining width. Card1 is already stretched, but Card2 and Card3 are inside a flex column and a ...

ways to clear the float on the right side of an image

So I have two images that I am trying to float, like this: img{ float:left; clear:right; } <img src='http://img1.imgtn.bdimg.com/it/u=1005212286,2432746147&fm=21&gp=0.jpg' alt=''><br> <img src ...

Prolong the duration before the submenu closes on a div-based css menu

I have created a unique horizontal menu using DIVs without the use of ul and li lists. Currently, I am searching for a way to delay the collapse of the submenus when the mouse moves out. I don't mind if the solution involves JavaScript, jQuery, or CSS ...

Alignment vertically in a Razor view

Here is a snippet of code I am working with: <p> @Html.LabelFor(m => m.address, new { style="vertical-align: middle;" }) @Html.TextAreaFor(m => m.address, new { @class = "addition ", value = "",rows="4", required = "required" }) </p> A ...

Tips for setting up personalized breakpoints for a Bootstrap navbar

I am currently facing an issue with my navbar on tablet view. Despite implementing custom breakpoints to collapse the navbar at 1050, the menu bar is appearing in two rows instead of one. I have tried using the code below but it doesn't seem to be wor ...

Troubleshooting a Scrolling Problem in AngularJS页面

My web page design incorporates a header, content body, and footer using Responsive and Angular Material. Within the Content Body, there is an md-content element containing multiple text paragraphs enclosed in <p>. I have set the overflow to auto (ov ...

Bespoke animated angular material tabs

Having an issue with Angular Material tabs. I have managed to remove the "slide" effect, but I can't figure out how to modify or remove the black effect behind my tab. Can anyone offer some assistance? black effect 1 black effect 2 Here is a snippe ...

Learn the trick to make this floating icon descend gracefully and stick around!

I'm trying to create a scrolling effect for icons on my website where they stay fixed after scrolling down a certain number of pixels. I've managed to make the header fixed after scrolling, but I'm unsure how to achieve this specific effect. ...

jQuery 'if' condition not getting detected

My jQuery code is not recognizing an if statement. You can check out the CodePen link here. On my site, I have 4 page transitions - page right, page left, page up, and page down. The contact page is hidden beneath the main hero sections and appears with t ...